I've been having problems getting uploads to work using libapreq2-2.03_04-dev.
I finally have it working, but I thought I would post my story for the benefit
of others.
Originally I was doing the upload like this:
my $bb = $r->upload('file')->bb();
open(OUT,">/tmp/test_file");
while (1) {
my $b = $bb->first;
last unless $b;
$b->remove;
my $data;
$b->read($data);
print OUT $data;
}
close OUT;
Small files were working ok, but large files where being truncated at about 270k
(which is suspiciously close to the 256k "zero copy limit" I saw mentioned on
[EMAIL PROTECTED]).
To make a long story short, here is the version that works:
my $bb = $r->upload('file')->bb();
open(OUT,">/tmp/test_file");
while (1) {
my $b = $bb->first;
last unless $b;
my $data;
$b->read($data);
print OUT $data;
$b->remove; # <--- ta da!
}
close OUT;
Notice that the only thing which changed was the position of the $b->remove
call. Call it too soon and your upload is unreliable.
Request for libapreq2 developers: Could you please either remove or document
this gotcha?
I also got upload->link to work, but I would have more confidence in that method
(Request #2) if the default value of TEMP_DIR was documented. Mason does not
currently provide a way to pass a TEMP_DIR to Apache::Request->new.
~ John Williams
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html