[dancer-users] send_file and Dancer2

Jean-Marc Choulet jm130794 at gmail.com
Wed Oct 15 13:42:45 BST 2014


Hello,

I 'am new to Dancer2 and I tried to migrate some code from mod_perl to 
Dancer2. Somewhere, I have this mod_perl code :

sub handler {
     ...

     open my $fh, "<$filename" or die $@;
     binmode $fh;

     $req->content_type('application/vnd.oasis.opendocument.spreadsheet');
     $req->headers_out->{'Content-Disposition'} = "attachment; filename=$file";

     my ($n, $data);
     while ($n = read($fh, $data, 1024)) {
         $req->print($data);
     }

     close($fh);

     return Apache2::Const::OK;
}

The mod_perl code send a OpenOffice document to the client.

How can I do the same thing with Dancer2 ?

Thanks,

Jean-Marc



More information about the dancer-users mailing list