| 1 | package Image::Delivery::Provider::File; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use base 'Image::Delivery::Provider::Scalar'; | ||
| 5 | use File::Slurp (); | ||
| 6 | |||
| 7 | use vars qw{$VERSION}; | ||
| 8 | BEGIN { | ||
| 9 | $VERSION = '0.14'; | ||
| 10 | } | ||
| 11 | |||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | ##################################################################### | ||
| 17 | # Constructor | ||
| 18 | |||
| 19 | sub new { | ||
| 20 | my $class = shift; | ||
| 21 | my $file = (defined $_[0] and -f $_[0] and -r _) ? shift : return undef; | ||
| 22 | |||
| 23 | # Slurp in the image | ||
| 24 | my $image = File::Slurp::read_file( $file, scalar_ref => 1 ); | ||
| 25 | return undef unless ref $image eq 'SCALAR'; | ||
| 26 | |||
| 27 | # Hand off to our parent | ||
| 28 | $class->SUPER::new( $image, @_ ); | ||
| 29 | } | ||
| 30 | |||
| 31 | 1; |