[Catalyst] Catalyst::Response - send a file
Dermot
paikkos at googlemail.com
Tue Aug 19 14:27:31 BST 2008
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
>>
>> $res->sendfile($filepath,0,$length); # Ok no such method but
>> hopefully you'll get what I mean.
>>
>> }
>
> open my $filehandle, '<', $filepath
> or die $!;
>
> $c->response->body( $filehandle );
Sorry. I mustn't be making myself clear.
I want the browser to offer the user a 'save as' dialogue box. The
modperl equivalent would be the RequestIO::sendfile
The above sends the contents of filepath to the browser
Thanx,
Dp.
More information about the Catalyst
mailing list