| 1 | package Silki::Role::Controller::File; | ||
| 2 | { | ||
| 3 | $Silki::Role::Controller::File::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use Moose::Role; | ||
| 11 | |||
| 12 | sub _serve_image { | ||
| 13 | my $self = shift; | ||
| 14 | my $c = shift; | ||
| 15 | my $file = shift; | ||
| 16 | my $meth = shift; | ||
| 17 | |||
| 18 | my $image = $file->$meth(); | ||
| 19 | |||
| 20 | $c->response()->status(200); | ||
| 21 | $c->response()->content_type( $file->mime_type() ); | ||
| 22 | $c->response()->content_length( -s $image ); | ||
| 23 | $c->response()->header( 'X-Sendfile' => $image ); | ||
| 24 | |||
| 25 | $c->detach(); | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; |