From b9f975834b4e5b5850d4b11021f598f8044b91f7 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 30 May 2012 17:09:04 +0100 Subject: Store compiled photos on file system. --- .gitignore | 1 + perllib/FixMyStreet/App/Controller/Photo.pm | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 974d01d6b..30daa380c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ tags /web/css/main.css /web/cobrands/fixmystreet/*.css /web/cobrands/bromley/*.css +/web/photo /local /web/cobrands/fixmystreet/compass_app_log.txt diff --git a/perllib/FixMyStreet/App/Controller/Photo.pm b/perllib/FixMyStreet/App/Controller/Photo.pm index a6717fc33..fc4c3fde7 100644 --- a/perllib/FixMyStreet/App/Controller/Photo.pm +++ b/perllib/FixMyStreet/App/Controller/Photo.pm @@ -6,6 +6,8 @@ BEGIN {extends 'Catalyst::Controller'; } use DateTime::Format::HTTP; use Digest::SHA1 qw(sha1_hex); +use File::Path; +use File::Slurp; use Path::Class; =head1 NAME @@ -95,6 +97,10 @@ sub index :LocalRegex('^(c/)?(\d+)(?:\.(full|tn|fp))?\.jpeg$') { sub output : Private { my ( $self, $c, $photo ) = @_; + # Save to file + File::Path::make_path( FixMyStreet->path_to( 'web', 'photo', 'c' )->stringify ); + File::Slurp::write_file( FixMyStreet->path_to( 'web', $c->req->path )->stringify, \$photo ); + my $dt = DateTime->now()->add( years => 1 ); $c->res->content_type( 'image/jpeg' ); -- cgit v1.2.3