This won't actually run the transaction, you need to start it with a
UserAgent object:
my $ua = Mojo::UserAgent;
$tx = $ua->start($tx);

Or just use the UserAgent post() method which will build and start the
transaction for you.

On Tue, Apr 21, 2015 at 2:41 AM, Pavel Serikov <[email protected]>
wrote:

> Greetings,
>
> I need to upload files on server using Mojo
>
> Can anyone explain me how to do it on simple example below?
>
> I run with morbo on http://127.0.0.1:3000 this app:
>
> #!/usr/bin/env perl
> use Mojolicious::Lite;
>
> post '/' => sub {
>   my $self = shift;
>   my $upload = $self->param('model');
>   my $name = $upload->filename;
>   warn $name;
>   $self->render(text => 'OK');
> };
>
> app->start;
>
> And run this file upload script (called it test.pl):
>
> use Mojo::UserAgent::Transactor;
> use Data::Dumper;
>
> my $t = Mojo::UserAgent::Transactor->new;
> my $tx = $t->tx(POST => 'http://127.0.0.1:3000' => form => {model => {file
> => 'stick.stl'}});
> my $result = $tx->res->to_string;
> warn Dumper $result;
>
> on output of ./test.pl I have:
>
> $VAR1 = 'HTTP/1.1 404 Not Found
> Content-Length: 0
> Date: Tue, 21 Apr 2015 05:37:21 GMT
> ';
>
> And no one warn output in server log, only regular
>
> [Tue Apr 21 09:33:24 2015] [info] Listening at "http://*:3000";.
>> Server available at http://127.0.0.1:3000.
>
>
> What I did wrong?
>
>
>
>  --
> 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 http://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 http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to