gstorage.storage

Implement the interface expected by django.core.files.storage.Storage

>>> from django.core.files.uploadfile import TemporaryUploadedFile
>>> from gstorage.storage import Storage
>>> storage = Storage(location='media/2016')
>>> with TemporaryUploadedFile('test', 'text/plain', 1, 'utf8') as content:
...     storage.save('test.txt', content)
...
>>> u'media/2016/test'
class gstorage.storage.Storage(location=None, base_url=None, bucket=None)
accessed_time(name)

Returns the last accessed time (as datetime object) of the file specified by name.

created_time(name)

Returns the creation time (as datetime object) of the file specified by name.

delete(name)

Deletes the specified file from the storage system.

exists(name)

Returns True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.

get_available_name(name)

Returns a filename that’s free on the target storage system, and available for new content to be written to.

get_valid_name(name)

Returns a filename, based on the provided filename, that’s suitable for use in the target storage system.

listdir(path)

Lists the contents of the specified path, returning a 2-tuple of lists; the first item being directories, the second item being files.

modified_time(name)

Returns the last modified time (as datetime object) of the file specified by name.

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.

size(name)

Returns the total size, in bytes, of the file specified by name.

url(name)

Returns an absolute URL where the file’s contents can be accessed directly by a Web browser.