Buckets and Files¶
Manage buckets and files on the server.
-
class
renga.models.storage.
BucketCollection
(client=None)[source]¶ Represent storage buckets on the server.
Create a representation of objects on the server.
-
backends
¶ Return a list of the enabled backends.
-
list
()¶ Return a list if the collection is iterable.
-
Bucket objects¶
Files¶
Manage files in the bucket.
-
class
renga.models.storage.
FileCollection
(bucket, **kwargs)[source]¶ Represent files in a bucket on the server.
Initialize collection of files in the bucket.
-
from_url
(url, filename=None)[source]¶ Create a file with data from the streamed GET response.
Example
>>> file_ = client.buckets[1234].files.from_url( ... 'https://example.com/tests/data', filename='hello') >>> file_.id 9876 >>> client.buckets[1234].files[9876].open('r').read() b'hello world'
-
list
()¶ Return a list if the collection is iterable.
-
File objects¶
-
class
renga.models.storage.
File
[source]¶ Represent a file object.
Create a representation of an object on the server.
-
access_token
¶ The access token for performing file operations.
-
filename
¶ Filename of the file.
-
id
¶ The identifier of the object.
-
open
(mode='r')¶ Return the
FileHandle
instance.
-
versions
¶ An object for managing file versions.
Returns: The collection of file versions. Return type: renga.models.storage.FileVersionCollection
-
File handle objects¶
-
class
renga.models.storage.
FileHandle
[source]¶ An object exposing a pythonic file-oriented API.
Depending on the bucket to which it belongs to, a file object can mediate access to different storage backends (local, Swift, etc).
Create a representation of an object on the server.
-
can_read
¶ Check if the file handle is readable.
-
can_write
¶ Check if the file handle is writable.
-
from_url
(url)[source]¶ Write data from the streamed GET response from the given URL.
Example
>>> with client.buckets[1234].files[9876].open('w') as fp: ... fp.from_url('https://example.com/tests/data')
-
id
¶ The identifier of the object.
-
File versions¶
-
class
renga.models.storage.
FileVersionCollection
(file_, **kwargs)[source]¶ Represent file versions of a file stored on the server.
Initialize a collection of file versions.
-
class
Meta
[source]¶ Information about individual file versions.
-
model
¶ alias of
FileVersion
-
-
list
()¶ Return a list if the collection is iterable.
-
class
-
class
renga.models.storage.
FileVersion
(response=None, client=None, collection=None)[source]¶ Represent a file version object.
Create a representation of an object on the server.
-
created
¶ Return file creation date and time.
-
filename
¶ Filename of the file.
-
id
¶ The identifier of the object.
-
open
(mode='r')¶ Return the
FileHandle
instance.
-