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 representation of objects on the server.
-
backends
¶ Return a list of the enabled backends.
-
list
()¶ Return 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, file_name=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', file_name='hello') >>> file_.open('r').read() b'hello world'
-
list
()¶ Return list if the collection is iterable.
-
File objects¶
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 representation of 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[1234].open('w') as fp: ... fp.from_url('https://example.com/tests/data')
-
id
¶ The identifier of the object.
-