Hi,
I solve it: problem is multipart boundary.
In sub Content::MultiPart::build_boundary(),
is file read (and not only once) unless boundary is already specified.
My workaround is:
post upload => sub {
my $ctrl = shift;
my $upload = $ctrl->upload('file');
if( $upload ) {
$upload->move_to('temp-uploaded-file.txt');
my $tx = $ctrl->ua->build_form_tx(
file.txt' }});
# boudnary workaround
my $ct = $tx->req->headers->content_type;
my $b = gen_random_boundary();
$tx->req->headers->content_type("$ct; boundary=$b);
$ctrl->ua->start($tx, sub { "to make this non-blocking"; });
}
} => 'thank-you';
But I think, it should be considered as bug, or give programmer more
convenient way to say 'I don't want Mojolicous reads all upload file
more than
once before actual upload'.
vitas
@;;