Add support for Google Cloud Storage.

This commit is contained in:
Jake Moshenko 2014-08-12 02:06:44 -04:00
parent b9c6c4c2f2
commit 29f1b048a3
3 changed files with 72 additions and 40 deletions

View file

@ -1,9 +1,16 @@
from storage.local import LocalStorage
from storage.s3 import S3Storage
from storage.cloud import S3Storage, GoogleCloudStorage
from storage.fakestorage import FakeStorage
from storage.distributedstorage import DistributedStorage
STORAGE_DRIVER_CLASSES = {
'LocalStorage': LocalStorage,
'S3Storage': S3Storage,
'GoogleCloudStorage': GoogleCloudStorage,
}
class Storage(object):
def __init__(self, app=None):
self.app = app
@ -18,13 +25,8 @@ class Storage(object):
driver = storage_params[0]
parameters = storage_params[1]
if driver == 'LocalStorage':
storage = LocalStorage(**parameters)
elif driver == 'S3Storage':
storage = S3Storage(**parameters)
else:
storage = FakeStorage()
driver_class = STORAGE_DRIVER_CLASSES.get(driver, FakeStorage)
storage = driver_class(**parameters)
storages[location] = storage
preference = app.config.get('DISTRIBUTED_STORAGE_PREFERENCE', None)