Blobs creation, retrieval, deletion and flagging¶
The BlobManager
class is responsible for blobs creation, retrieval,
deletion, flagging and synchronizing. For better code organization, the methods
related to synchronization are implemented separatelly in a superclass (see
Blobs Synchronization).
-
class
leap.soledad.client._db.blobs.
BlobManager
(local_path, remote, key, secret, user, token=None, cert_file=None, remote_stream=None)[source]¶ Bases:
leap.soledad.client._db.blobs.sync.BlobsSynchronizer
The BlobManager can list, put, get, set flags and synchronize blobs stored in local and remote storages.
-
__init__
(local_path, remote, key, secret, user, token=None, cert_file=None, remote_stream=None)[source]¶ Initialize the blob manager.
Parameters: - local_path (str) – The path for the local blobs database.
- remote (str) – The URL of the remote storage.
- secret (str) – The secret used to encrypt/decrypt blobs.
- user (str) – The uuid of the user.
- token (str) – The access token for interacting with remote storage.
- cert_file (str) – The path to the CA certificate file.
- remote_stream (str) – Remote storage stream URL, if supported.
-
concurrent_transfers_limit
= 3¶
-
concurrent_writes_limit
= 100¶
-
count
(namespace='')[source]¶ Count the number of blobs.
Parameters: namespace (str) – Optional parameter to restrict operation to a given namespace. Returns: A deferred that fires with a dict parsed from the JSON response, which count key has the number of blobs as value. Eg.: {“count”: 42} Return type: twisted.internet.defer.Deferred
-
delete
(blob_id, namespace='')[source]¶ Delete a blob from local and remote storages.
Parameters: - blob_id (str) – Unique identifier of a blob.
- namespace (str) – Optional parameter to restrict operation to a given namespace.
Returns: A deferred that fires when the operation finishes.
Return type: twisted.internet.defer.Deferred
-
get
(**kwargs)[source]¶ Get the blob from local storage or, if not available, from the server.
Parameters: - blob_id (str) – Unique identifier of a blob.
- namespace (str) – Optional parameter to restrict operation to a given namespace.
- priority (str) – Priority for blob download (one of: low, medium, high, urgent)
Returns: A deferred that fires with the file descriptor for the contents of the blob.
Return type: twisted.internet.defer.Deferred
-
get_flags
(**kwargs)[source]¶ Get flags from a given blob_id.
Parameters: - blob_id (str) – Unique identifier of a blob.
- namespace (str) – Optional parameter to restrict operation to a given namespace.
Returns: A deferred that fires with a list parsed from JSON response. Eg.: [Flags.PENDING]
Return type: twisted.internet.defer.Deferred
-
max_decrypt_retries
= 3¶
-
put
(doc, size, namespace='', local_only=False, priority=2)[source]¶ Put a blob in local storage and upload it to server.
Parameters: - doc (leap.soledad.client._document.BlobDoc) – A BlobDoc representing the blob.
- size (int) – The size of the blob.
- namespace (str) – Optional parameter to restrict operation to a given namespace.
- local_only (bool) – Avoids sync (doesn’t send to server).
- priority (str) – Priority for blob upload (one of: low, medium, high, urgent)
Returns: A deferred that fires when the blob has been put.
Return type: twisted.internet.defer.Deferred
-
remote_list
(**kwargs)[source]¶ List blobs from server, with filtering and ordering capabilities.
Parameters: - namespace (str) – Optional parameter to restrict operation to a given namespace.
- order_by (str) – Optional parameter to order results. Possible values are: date or +date - Ascending order (older first) -date - Descending order (newer first)
- deleted – Optional paramter to return only deleted blobs.
- filter_flag (leap.soledad.common.blobs.Flags) – Optional parameter to filter listing to results containing the specified tag.
- only_count (bool) – Optional paramter to return only the number of blobs found.
Returns: A deferred that fires with a list parsed from the JSON response, holding the requested list of blobs. Eg.: [‘blob_id1’, ‘blob_id2’]
Return type: twisted.internet.defer.Deferred
-
set_flags
(blob_id, flags, namespace='')[source]¶ Set flags for a given blob_id.
Parameters: - blob_id (str) – Unique identifier of a blob.
- flags ([leap.soledad.common.blobs.Flags]) – List of flags to be set.
- namespace (str) – Optional parameter to restrict operation to a given namespace.
Returns: A deferred that fires when the operation finishes.
Return type: twisted.internet.defer.Deferred
-