core.files.storage._open()

_open(name, mode='rb') Required. Called by Storage.open(), this is the actual mechanism the storage class uses to open the file. This must return a File object, though in most cases, you’ll want to return some subclass here that implements logic specific to the backend storage system.

core.files.storage._save()

_save(name, content) Called by Storage.save(). The name will already have gone through get_valid_name() and get_available_name(), and the content will be a File object itself. Should return the actual name of name of the file saved (usually the name passed in, but if the storage needs to change the file name return the new name instead).

core.files.storage.Storage.url()

url(name) [source] Returns the URL where the contents of the file referenced by name can be accessed. For storage systems that don’t support access by URL this will raise NotImplementedError instead.

core.files.storage.Storage.size()

size(name) [source] Returns the total size, in bytes, of the file referenced by name. For storage systems that aren’t able to return the file size this will raise NotImplementedError instead.

core.files.storage.Storage.path()

path(name) [source] The local filesystem path where the file can be opened using Python’s standard open(). For storage systems that aren’t accessible from the local filesystem, this will raise NotImplementedError instead.

core.files.storage.Storage.save()

save(name, content, max_length=None) [source] Saves a new file using the storage system, preferably with the name specified. If there already exists a file with this name name, the storage system may modify the filename as necessary to get a unique name. The actual name of the stored file will be returned. The max_length argument is passed along to get_available_name(). The content argument must be an instance of django.core.files.File or a file-like object that can be wrapped in File.

core.files.storage.Storage.listdir()

listdir(path) [source] Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files. For storage systems that aren’t able to provide such a listing, this will raise a NotImplementedError instead.

core.files.storage.Storage.modified_time()

modified_time(name) [source] Returns a naive datetime object containing the last modified time. For storage systems that aren’t able to return the last modified time, this will raise NotImplementedError instead. Deprecated since version 1.10: Use get_modified_time() instead.

core.files.storage.Storage.get_modified_time()

get_modified_time(name) [source] New in Django 1.10. Returns a datetime of the last modified time of the file. For storage systems unable to return the last modified time this will raise NotImplementedError. If USE_TZ is True, returns an aware datetime, otherwise returns a naive datetime in the local timezone.

core.files.storage.Storage.open()

open(name, mode='rb') [source] Opens the file given by name. Note that although the returned file is guaranteed to be a File object, it might actually be some subclass. In the case of remote file storage this means that reading/writing could be quite slow, so be warned.