i just figured something like this out on perlmonks.org:
http://www.perlmonks.org/index.pl?node_id=320770


On Fri, 2004-01-16 at 11:02, Joe Schaefer wrote:
> "Pete Smith" <[EMAIL PROTECTED]> writes:
> 
> [...]
> 
> > my $image_upload = $r->upload('image');
> > my $file_handle = $image_upload->fh();
> > 
> > read ($file_handle, my $full_image_data, (stat($file_handle))[7]);
> > 
> > my $imager = Imager->new();
> > 
> > $imager->open(data => $full_image_data, type => 'jpeg');
> > my ($width) = imgsize(\$full_image_data);
> > 
> > 
> > I now know that I could pass the file handle to Imager and Image::Size
> > instead of turning into a scalar stream, but that isn't the problem.
> > 
> > I have discovered that Apache::Request for mod_perl2 has changed the
> > fh method to bb, which apparently returns an APR::Brigade (object I
> > presume) instead of a file handle. 
> > 
> > I have looked for documentation for APR::Brigade, but can find none. I
> > have no idea what it is!
> 
> APR::Brigade is, well, the perl glue for libaprutil's apr_brigade_t C struct.  
> Along with buckets, they are used throughout the filter api, both in
> apache2 and mp2 (collectively referred to as "bucket brigades").
> 
> > Could somebody please point me in the right direction as to how I can
> > achieve the above in mod_perl2?
> 
> In your mp1 code, you are simply slurping the upload into
> $full_image_data; with apreq2 you can do that with a bucket 
> brigade via
> 
>   my $bb = $req->upload('image')->bb;
>   my $full_image_data = "";
> 
>   while (my $b = $bb->first) {
>      $b->read(my $buffer);
>      $full_image_data .= $buffer;
>      $b->remove;
>   }
> 
> I'm sure there are better ways to use the brigade API
> though.  The C API for brigades has a "flatten" function- 
> does anyone know if mp2 has glue for that yet?
> 
> -- 
> Joe Schaefer
-- 
Clayton Cottingham - WinterMarket Networks
Virtual Reality Programming, Design & Evangelist
Phone:(604) 875-1213
Cell: (604) 506-7230
Vancouver, B.C. Canada
[EMAIL PROTECTED]
http://www.wintermarket.net
IM's icq:154964789 hotmail:[EMAIL PROTECTED]
yahoo:[EMAIL PROTECTED]


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html

Reply via email to