added user upload limits

This commit is contained in:
Rodney Ewing
2013-06-12 12:02:11 -07:00
parent 0cdebda7fc
commit bdd2242155
8 changed files with 82 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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