[Catalyst] Catalyst::Response - send a file

Dermot paikkos at googlemail.com
Tue Aug 19 12:30:39 BST 2008


I am looking for a method to send a file in response to a request. My
effort is below and all this does is print the file's path on the
page. I can't set the content-disposition or see find an obvious
method in C::Response or C::Request.

Am I looking in the wrong place? Can someone point me in the right direction.

sub downloadFile {

  my ($name, $filepath) = @_;

  my $length = (stat($filepath))[7];
  my $res = $c->response;

  $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.


More information about the Catalyst mailing list