[Catalyst] Catalyst::Response - send a file

Bogdan Lucaciu bogdan at wiz.ro
Tue Aug 19 14:55:55 BST 2008


On Tuesday 19 August 2008 16:41:40 Carl Franks wrote:
> You'll still need the body($fh) bit to send the data, too.

Or, if you use Catalyst::Plugin::Static::Simple, you can use:

$c->serve_static_file($file_path);

some code snippets from that method:

    $c->res->headers->content_type( $type );
    $c->res->headers->content_length( $stat->size );
    $c->res->headers->last_modified( $stat->mtime );
..
	my $fh = IO::File->new( $full_path, 'r' );
..
            binmode $fh;
            $c->res->body( $fh );

-- 
Bogdan Lucaciu
http://www.wiz.ro



More information about the Catalyst mailing list