I want to send large files via post, but this time did not 'multipart / 
form-data' head. 
like this 

use Mojo::UserAgent;
use Mojo::Asset::File;

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

$ua->post('http://f.xxx.com:3000/upload' => stream => '/root/index.html');


I do not want to generate a temporary file. It is not appropriate to use 
upload method to handle. I wrote this hook below. 


hook after_build_tx => sub {
  my $tx = shift;

  weaken $tx;
  $tx->req->content->on(  body => sub {
        my $content = shift;
        $content->unsubscribe('read');
        $content->on(read => sub {
            my ($content, $bytes) = @_; 
            say "Streaming: $bytes";
        }); 
  }); 
};


This does not work properly, or will generate Mojo :: Asset :: File object. I 
hope it nonblocking write files, so more than one person the right to upload 
large 
files.I want to ask how to write in order to stream the hook receiving large 
files?

-- 
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