Backends¶
-
class
queued_storage.backends.QueuedStorage(local=None, remote=None, local_options=None, remote_options=None, cache_prefix=None, delayed=None, task=None)¶ Base class for queued storages. You can use this to specify your own backends.
Parameters: - local (str) – local storage class to transfer from
- local_options (dict) – options of the local storage class
- remote (str) – remote storage class to transfer to
- remote_options (dict) – options of the remote storage class
- cache_prefix (str) – prefix to use in the cache key
- delayed (bool) – whether the transfer task should be executed automatically
- task (str) – Celery task to use for the transfer
-
local_options= None¶ The options of the local storage class, defined as a dictionary.
-
local= None¶ The local storage class to use. A dotted path (e.g.
'django.core.files.storage.FileSystemStorage').
-
remote_options= None¶ The options of the remote storage class, defined as a dictionary.
-
remote= None¶ The remote storage class to use. A dotted path (e.g.
'django.core.files.storage.FileSystemStorage').
-
task= 'queued_storage.tasks.Transfer'¶ The Celery task class to use to transfer files from the local to the remote storage. A dotted path (e.g.
'queued_storage.tasks.Transfer').
-
delayed= False¶ If set to
Truethe backend will not transfer files to the remote location automatically, but instead requires manual intervention by the user with thetransfer()method.
-
cache_prefix= 'queued_storage'¶ The cache key prefix to use when saving the which storage backend to use, local or remote (default see
QUEUED_STORAGE_CACHE_PREFIX)
-
get_storage(name)¶ Returns the storage backend instance responsible for the file with the given name (either local or remote). This method is used in most of the storage API methods.
Parameters: name (str) – file name Return type: Storage
-
get_cache_key(name)¶ Returns the cache key for the given file name.
Parameters: name (str) – file name Return type: str
-
using_local(name)¶ Determines for the file with the given name whether the local storage is current used.
Parameters: name (str) – file name Return type: bool
-
using_remote(name)¶ Determines for the file with the given name whether the remote storage is current used.
Parameters: name (str) – file name Return type: bool
-
open(name, mode='rb')¶ Retrieves the specified file from storage.
Parameters: Return type:
-
save(name, content, max_length=None)¶ Saves the given content with the given name using the local storage. If the
delayedattribute isTruethis will automatically call thetransfer()method queuing the transfer from local to remote storage.Parameters: Return type:
-
transfer(name, cache_key=None)¶ Transfers the file with the given name to the remote storage backend by queuing the task.
Parameters: Return type: task result
-
get_valid_name(name)¶ Returns a filename, based on the provided filename, that’s suitable for use in the current storage system.
Parameters: name (str) – file name Return type: str
-
get_available_name(name)¶ Returns a filename that’s free on both the local and remote storage systems, and available for new content to be written to.
Parameters: name (str) – file name Return type: str
-
path(name)¶ Returns a local filesystem path where the file can be retrieved using Python’s built-in open() function. Storage systems that can’t be accessed using open() should not implement this method.
Parameters: name (str) – file name Return type: str
-
exists(name)¶ Returns
Trueif a file referened by the given name already exists in the storage system, or False if the name is available for a new file.Parameters: name (str) – file name Return type: bool
-
listdir(name)¶ Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files.
Parameters: name (str) – file name Return type: tuple
-
size(name)¶ Returns the total size, in bytes, of the file specified by name.
Parameters: name (str) – file name Return type: int
-
url(name)¶ Returns an absolute URL where the file’s contents can be accessed directly by a Web browser.
Parameters: name (str) – file name Return type: str
-
accessed_time(name)¶ Returns the last accessed time (as datetime object) of the file specified by name.
Parameters: name (str) – file name Return type: datetime
-
created_time(name)¶ Returns the creation time (as datetime object) of the file specified by name.
Parameters: name (str) – file name Return type: datetime
-
modified_time(name)¶ Returns the last modified time (as datetime object) of the file specified by name.
Parameters: name (str) – file name Return type: datetime
-
get_accessed_time(name)¶ Django +1.10 Returns the last accessed time (as datetime object) of the file specified by name.
Parameters: name (str) – file name Return type: datetime
-
get_created_time(name)¶ Django +1.10 Returns the creation time (as datetime object) of the file specified by name.
Parameters: name (str) – file name Return type: datetime
-
get_modified_time(name)¶ Django +1.10 Returns the last modified time (as datetime object) of the file specified by name.
Parameters: name (str) – file name Return type: datetime
-
generate_filename(filename)¶
-
class
queued_storage.backends.QueuedFileSystemStorage(local='django.core.files.storage.FileSystemStorage', *args, **kwargs)¶ A
QueuedStoragesubclass which conveniently usesFileSystemStorageas the local storage.
-
class
queued_storage.backends.QueuedS3BotoStorage(remote='storages.backends.s3boto.S3BotoStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theS3BotoStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedCouchDBStorage(remote='storages.backends.couchdb.CouchDBStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theCouchDBStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedDatabaseStorage(remote='storages.backends.database.DatabaseStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theDatabaseStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedFTPStorage(remote='storages.backends.ftp.FTPStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theFTPStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedMogileFSStorage(remote='storages.backends.mogile.MogileFSStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theMogileFSStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedGridFSStorage(remote='storages.backends.mongodb.GridFSStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theGridFSStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedCloudFilesStorage(remote='storages.backends.mosso.CloudFilesStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theCloudFilesStoragestorage of the django-storages app as the remote storage.
-
class
queued_storage.backends.QueuedSFTPStorage(remote='storages.backends.sftpstorage.SFTPStorage', *args, **kwargs)¶ A custom
QueuedFileSystemStoragesubclass which uses theSFTPStoragestorage of the django-storages app as the remote storage.