added user upload limits
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user