[Catalyst] Question on serving files

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Fri Feb 16 17:14:55 GMT 2007







<joeandjackie at boltblue.com> wrote on 02/16/2007 10:45:12 AM:

> Hi,
>
> I have a catalyst application which displays a list of files in a
directory.
> I would like to provide an anchor on the files to have them
downloadaccording
> to their
> mime-type.
> e.g. Clicking on a link to an excel file will stream the file with
mime-type
> application/excel just as though it came from an indexed folder.
>
> How do I do this through the Catalyst handler & response mechanism?
>
> Thanks,
>
> Joe


You can set the header information to give mime hints to the browser:

      $c->res->headers->content_type('application/octet-stream');
        $c->res->headers->content_length( $stat->size );
        $c->res->headers->last_modified( $stat->mtime );
        $c->response->headers->header(
            'Content-disposition:' => "attachment; filename=$filename" );
        $c->res->headers->expires( time() );
        $c->res->headers->header( 'Pragma'        => 'no-cache' );
        $c->res->headers->header( 'Cache-Control' => 'no-cache' );


for instance would force the file to download prompt (no cache) even if
there was a healer listed for the extension on all major browsers.




>
>
> --------------------------------------------------------------
> Sent with "Me-Mail", Boltblue's FREE mobile messaging service.
> http://www.boltblue.com
>
>
> _______________________________________________
> List: Catalyst at lists.rawmode.org
> Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
> Searchable archive:
http://www.mail-archive.com/catalyst@lists.rawmode.org/
> Dev site: http://dev.catalyst.perl.org/




More information about the Catalyst mailing list