diff options
author | Rodney Ewing <ewing.rj@gmail.com> | 2013-06-12 12:02:11 -0700 |
---|---|---|
committer | Rodney Ewing <ewing.rj@gmail.com> | 2013-08-26 06:33:28 -0700 |
commit | bdd2242155d3192615740661ce52f6fb960d1a05 (patch) | |
tree | 54599b61d8f75e43552932b07792eefd41f21e2a /mediagoblin/storage | |
parent | 0cdebda7fc533384bd725412365325edcbeb038c (diff) | |
download | mediagoblin-bdd2242155d3192615740661ce52f6fb960d1a05.tar.lz mediagoblin-bdd2242155d3192615740661ce52f6fb960d1a05.tar.xz mediagoblin-bdd2242155d3192615740661ce52f6fb960d1a05.zip |
added user upload limits
Diffstat (limited to 'mediagoblin/storage')
-rw-r--r-- | mediagoblin/storage/__init__.py | 7 | ||||
-rw-r--r-- | mediagoblin/storage/cloudfiles.py | 6 | ||||
-rw-r--r-- | mediagoblin/storage/filestorage.py | 3 |
3 files changed, 16 insertions, 0 deletions
diff --git a/mediagoblin/storage/__init__.py b/mediagoblin/storage/__init__.py index bbe134a7..51b46c07 100644 --- a/mediagoblin/storage/__init__.py +++ b/mediagoblin/storage/__init__.py @@ -191,6 +191,13 @@ class StorageInterface(object): # Copy to storage system in 4M chunks shutil.copyfileobj(source_file, dest_file, length=4*1048576) + def get_file_size(self, filepath): + """ + Return the size of the file in bytes. + """ + # Subclasses should override this method. + self.__raise_not_implemented() + ########### # Utilities diff --git a/mediagoblin/storage/cloudfiles.py b/mediagoblin/storage/cloudfiles.py index 250f06d4..47c81ad6 100644 --- a/mediagoblin/storage/cloudfiles.py +++ b/mediagoblin/storage/cloudfiles.py @@ -168,6 +168,12 @@ class CloudFilesStorage(StorageInterface): # Copy to storage system in 4096 byte chunks dest_file.send(source_file) + def get_file_size(self, filepath): + """Returns the file size in bytes""" + obj = self.container.get_object( + self._resolve_filepath(filepath)) + return obj.total_bytes + class CloudFilesStorageObjectWrapper(): """ Wrapper for python-cloudfiles's cloudfiles.storage_object.Object diff --git a/mediagoblin/storage/filestorage.py b/mediagoblin/storage/filestorage.py index 3d6e0753..29b8383b 100644 --- a/mediagoblin/storage/filestorage.py +++ b/mediagoblin/storage/filestorage.py @@ -111,3 +111,6 @@ class BasicFileStorage(StorageInterface): os.makedirs(directory) # This uses chunked copying of 16kb buffers (Py2.7): shutil.copy(filename, self.get_local_path(filepath)) + + def get_file_size(self, filepath): + return os.stat(self._resolve_filepath(filepath)).st_size |