[Catalyst] Question on serving files

Jonathan Rockway jon at jrock.us
Fri Feb 16 17:31:31 GMT 2007



joeandjackie at boltblue.com wrote:
> How do I do this through the Catalyst handler & response mechanism?

Just like you'd serve any other data (see other posts in the thread
for the details).  Get the data, set the headers, shove it into
$c->res->body.  You might want to use some sort of sendfile
implementation, though, for performance reasons.  Using a 100M
catalyst process to serve spreadsheets is a waste of resources.  (My
suggestion is to set cache control headers and then let your webserver
serve future requests from its cache.  Easy to set up, and as fast as
static pages after the first request.)

As for getting the directory listings, you'll probably want
Catalyst::Model::File.  For guessing the types of the files (the
hardest part of this exercise), File::MMagic::XS looks like a good
direction to go in.

Regards,
Jonathan Rockway

-- 
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;



More information about the Catalyst mailing list