aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/PhotoStorage.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2018-09-26 16:37:40 +0100
committerDave Arter <davea@mysociety.org>2018-09-28 16:19:47 +0100
commit561e01b9b51b62e2566d80cd63d308f9a4f82822 (patch)
treea5f5a9254e3c3f1536a7300b45582ad2ceae51d8 /perllib/FixMyStreet/PhotoStorage.pm
parent9b2b8675f6dfa22c45d609349f97730a33c975d3 (diff)
Factor out photo storage backend init checks
Diffstat (limited to 'perllib/FixMyStreet/PhotoStorage.pm')
-rw-r--r--perllib/FixMyStreet/PhotoStorage.pm13
1 files changed, 12 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/PhotoStorage.pm b/perllib/FixMyStreet/PhotoStorage.pm
index 99f0bdab6..a441fb718 100644
--- a/perllib/FixMyStreet/PhotoStorage.pm
+++ b/perllib/FixMyStreet/PhotoStorage.pm
@@ -2,7 +2,18 @@ package FixMyStreet::PhotoStorage;
use Moose;
use Digest::SHA qw(sha1_hex);
-
+use Module::Load;
+use FixMyStreet;
+
+our $instance; # our, so tests can set to undef when testing different backends
+sub backend {
+ return $instance if $instance;
+ my $class = 'FixMyStreet::PhotoStorage::';
+ $class .= FixMyStreet->config('PHOTO_STORAGE_BACKEND') || 'FileSystem';
+ load $class;
+ $instance = $class->new();
+ return $instance;
+}
sub detect_type {
my ($self, $photo) = @_;