If you want to move the asset somewhere, you can also use "move_to" on
the asset itself. And yes, it'll use different temp files, as far as I
know anyway :)


On 09/05/2016 09:59 AM, Pierre Pannetier wrote:
>
> Hi,
>
>
> sorry i'm a newbie with Mojo, and i have a question related
> toMojo::Asset::File if you don't mind. i am writing some API to
> receive a POST containing a pdf file :
>
>
> POST /documents HTTP/1.1
>
> Content-Disposition: form-data; name="myfile"; filename="myfile.pdf"
>
> Content-Type: application/pdf
>
>  etc..
>
>
> I see that Mojo is temporary storing the file uploaded into /tmp/mojo.tmp
>
>
> My first idea was to save the temporarly file
>
>
> `cp /tmp/mojo.tmp myfile.pdf`;
>
>
> What is going on if i run multiples workers with prefork and the
> service receive multiples upload simultaneously ? Does mojo use
> different tmp file names (ie : /tmp/mojo1.tmp, /tmp/mojo2.tmp) ?
>
>
> Otherwise, i could use $asset->slurp (see below), but slurp is
> returning lines before and after the the file content posted, and i
> have to clean it before use.
>
>
> ie :
> /------WebKitFormBoundaryZthpSWxw9tWBTrTj
> Content-Disposition: form-data; name="filepdf"; filename="msg.pdf"
> Content-Type: application/octet-stream
> /
>
> /etc.../
>
>
>   my $asset;
>   if ($self->req->content->is_multipart) {
>       $asset = $self->param('file')->asset;
>   } else {
>       $asset = $self->req->content->asset;
>   }
>
>   my $data=$asset->slurp;
>   $data=~s/^(?:.*\n){1,4}//;
>   $data=~s/(?:.*\n){1,2}\z//;
>   #print "[".$data."]\n";
>
>
> Finally
>
>
> Is there any way to only get the file content and only the file content ?
>
>
> Many thx.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to