[Catalyst] Serving "static" content from DB

Mihai Bazon mihai at bazon.net
Sat Jun 6 12:07:16 GMT 2009


Kieren Diment <kieren at diment.org> wrote:
> >
> > When serving an attachment, instead of always retrieving it from DB I
> > want to save them in a cache directory.  So the first time a file is
> > requested, it will be fetched from DB, saved in cache, then I want the
> > Web server to do the job as if it were a static file.  With plain
> > ModPerl, I would do it like this:
> >
> >  $r->filename($path_to_saved_file);
> >  # plus some more hacks if it runs after PerlMapToStorageHandler
> >  return Apache2::Const::DECLINED;
> 
> my $file = $c->path_to($something);
> if (!-e $file) ) {
> 	$c->model('DB::Files')->get_file(@args);
> }
> $c->serve_static_content($file); # part of  
> Catalyst::Plugin::Static::Simple

This seems close to what I need, thanks!

-Mihai


More information about the Catalyst mailing list