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]).
Interesting. What's the type of the bucket? Is that a file bucket? Try this code:
use APR::Brigade (); use APR::Bucket (); use APR::BucketType (); my $bb = $r->upload('file')->bb(); bb_dump($bb);
sub bb_dump { my($bb) = @_;
my @data; for (my $b = $bb->first; $b; $b = $bb->next($b)) { $b->read(my $bdata); push @data, $b->type->name, $bdata; }
unless (@data) { print STDERR " No buckets\n"; return; }
my $c = 1; while (my($btype, $data) = splice @data, 0, 2) { print STDERR " o bucket $c: $btype\n"; print STDERR "[$data]\n"; $c++; } }
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.
-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- 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