[Catalyst] Catalyst::Response - send a file
Ash Berlin
ash_cpan at firemirror.com
Tue Aug 19 14:38:19 BST 2008
On 19 Aug 2008, at 14:27, Dermot wrote:
> 2008/8/19 Carl Franks <fireartist at gmail.com>:
>> 2008/8/19 Dermot <paikkos at googlemail.com>:
>>> sub downloadFile {
>>>
>>> my ($name, $filepath) = @_;
>>>
>>> my $length = (stat($filepath))[7];
>>> my $res = $c->response;
>>> $res->content_length($length);
>>>
>>> $res->headers->({ 'Content-Disposition' =>
>>> "attachment;filename=$name"} ); # CODE ref error
Where did you get this syntax idea from? Since when has headers been
returning a coderef? Go read the docs again: http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7014/lib/Catalyst/Response.pm#$res-%3Eheader
Fix the above headers you have, and use the snippet luke gave below
>>
>> open my $filehandle, '<', $filepath
>> or die $!;
>>
>> $c->response->body( $filehandle );
>
>
More information about the Catalyst
mailing list