[Dancer-users] send_file Content-Disposition

Matthew Vickers mvickers at quispiam.com
Mon Feb 7 01:27:00 CET 2011


Hi All, 

I was having terrible trouble using send_file and the Content-Disposition header. I found that I needed to set the Content-Disposition header manually in the reponse object returned from send_file. 

get '/myfile' => sub { 
my $response = send_file('/some/file.jpg'); 
$response->header('Content-Disposition', "attachment; filename=some_other_file.jpg"); 
return $response; 
} 

Although this works and I have no problems doing it, it seems counter intuative. I would rather do: 

get '/myfile' => sub { 
header "Content-Disposition" => "attachment; filename=some_other_file.jpg" ; 
send_file('/some/file.jpg'); 
} 

In the highly likely event I am doing something wrong can someone let me know ? 

Cheers 

Matt. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110207/701dc090/attachment.htm>


More information about the Dancer-users mailing list