Skip to content

Commit

Permalink
better generator recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 12, 2013
1 parent 2a42051 commit 9c5776f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -984,16 +984,16 @@ use L<Mojo::UserAgent::Transactor> generators.
use Mojo::UserAgent;
use Mojo::Asset::File;

# Add "large" generator
# Add "stream" generator
my $ua = Mojo::UserAgent->new;
$ua->transactor->add_generator(large = sub {
$ua->transactor->add_generator(stream = sub {
my ($transactor, $tx, $path) = @_;
$tx->req->content->asset(Mojo::Asset::File->new(path => $path));
});

# Upload multiple files streaming via PUT
$ua->put('http://mojolicio.us/upload' => large => '/home/sri/mojo.png');
$ua->put('http://mojolicio.us/upload' => large => '/home/sri/mango.png');
# Upload multiple files streaming via PUT and POST
$ua->put('http://mojolicio.us/upload' => stream => '/home/sri/mojo.png');
$ua->post('http://mojolicio.us/upload' => stream => '/home/sri/mango.png');

=head2 Command line

Expand Down

0 comments on commit 9c5776f

Please sign in to comment.