See Plack::Request methods "parameters" and "uploads". This should be very familiar to you if you know CGI.pm.

Server (this is one line):

plackup -MPlack::Request -MDDP -e'my $app = sub { my ($env) = @_; my $ +req = Plack::Request->new($env); p $req->parameters; p $req->uploads; + return [200,[],[]]; };'

Client:

curl -v -F somekey=somevalue -F upload=@somefile http://localhost:5000

HTTP trace:

POST / HTTP/1.1 Host: localhost:5000 User-Agent: curl/7.65.0 Accept: */* Content-Length: 322 Content-Type: multipart/form-data; boundary=------------------------84 +f03d39abacb4c6 --------------------------84f03d39abacb4c6 Content-Disposition: form-data; name="somekey" somevalue --------------------------84f03d39abacb4c6 Content-Disposition: form-data; name="upload"; filename="somefile" Content-Type: application/octet-stream somefilecontent --------------------------84f03d39abacb4c6-- HTTP/1.0 200 OK Date: Fri, 14 Jun 2019 07:22:11 GMT Server: HTTP::Server::PSGI Content-Length: 0

Abbreviated server output:

Hash::MultiValue { public methods (24) : … private methods (2) : … internals: { somekey "somevalue" } } Hash::MultiValue { public methods (24) : … private methods (2) : … internals: { upload Plack::Request::Upload } } 127.0.0.1 - - [14/Jun/2019:09:22:11 +0200] "POST / HTTP/1.1" 200 0 "-" + "curl/7.65.0"

In reply to Re: Perl parsing of multipart content by daxim
in thread Perl parsing of multipart content by jeclark2006

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.