[Catalyst-dev] trouble with a pdf attachment

Andreas Marienborg omega at palle.net
Wed Nov 7 05:22:50 GMT 2012


On Nov 7, 2012, at 12:20 PM, Jillian Rowe <jir2004 at qatar-med.cornell.edu> wrote:

> Thanks! I tried out the File::Slurp just now, and it works perfectly!
> 
> Altogether its:
> 
> use File::Slurp;
> my $fileholder = read_file( $file );
> $c->res->content_type('application/pdf');
> $c->res->header('Content-Disposition', "attachment; filename=$name");
> $c->res->body( $fileholder );

https://metacpan.org/module/Catalyst::Response#res-body-text-fh-iohandle_object-

You could also pass in a filehandle, or a IO::Handle, and have Catalyst respond with pieces. That way you don't have to read the whole PDF into memory at once.

-a


More information about the Catalyst-dev mailing list