protocols.objstorage.ObjectStorageProtocol
Protocol for interacting with S3-like Object Storages.
Usage
protocols.objstorage.ObjectStorageProtocol()Classes
| Name | Description |
|---|---|
| BucketAlreadyExistsError | Thrown when trying to create a bucket with an ID that already exists. |
| BucketError | Generic base exception for error that occur while handling buckets. |
| BucketIdValidationError | Thrown when a bucket ID is not valid. |
| BucketNotEmptyError | Thrown when trying to delete a bucket that is not empty. |
| BucketNotFoundError | Thrown when trying to access a bucket with an ID that doesn’t exist. |
| MultiPartUploadAbortError | Thrown when failed to abort a multi-part upload. |
| MultiPartUploadAlreadyExistsError | Thrown when trying to create a multipart upload for an object for which another |
| MultiPartUploadConfirmError | Thrown when a confirmation of an upload is rejected. |
| MultiPartUploadError | Thrown when a confirmation of an upload is rejected. |
| MultiPartUploadNotFoundError | Thrown when a upload with the specified upload, bucket, and object id was not found. |
| MultipleActiveUploadsError | Thrown when multiple active multi-part uploads are detected for the same object. |
| ObjectAlreadyExistsError | Thrown when trying to access a file with an ID that doesn’t exist. |
| ObjectError | Generic base exception for error that occur while handling file objects. |
| ObjectIdValidationError | Thrown when an object ID is not valid. |
| ObjectNotFoundError | Thrown when trying to access a bucket with an ID that doesn’t exist. |
| ObjectStorageProtocolError | Generic base exception for all custom errors used by this protocol. |
BucketAlreadyExistsError
Thrown when trying to create a bucket with an ID that already exists.
Usage
BucketAlreadyExistsError()
BucketError
Generic base exception for error that occur while handling buckets.
Usage
BucketError()
BucketIdValidationError
Thrown when a bucket ID is not valid.
Usage
BucketIdValidationError()
BucketNotEmptyError
Thrown when trying to delete a bucket that is not empty.
Usage
BucketNotEmptyError()
BucketNotFoundError
Thrown when trying to access a bucket with an ID that doesn’t exist.
Usage
BucketNotFoundError()
MultiPartUploadAbortError
Thrown when failed to abort a multi-part upload.
Usage
MultiPartUploadAbortError()
MultiPartUploadAlreadyExistsError
Thrown when trying to create a multipart upload for an object for which another
Usage
MultiPartUploadAlreadyExistsError()upload is already active.
MultiPartUploadConfirmError
Thrown when a confirmation of an upload is rejected.
Usage
MultiPartUploadConfirmError()
MultiPartUploadError
Thrown when a confirmation of an upload is rejected.
Usage
MultiPartUploadError()
MultiPartUploadNotFoundError
Thrown when a upload with the specified upload, bucket, and object id was not found.
Usage
MultiPartUploadNotFoundError()
MultipleActiveUploadsError
Thrown when multiple active multi-part uploads are detected for the same object.
Usage
MultipleActiveUploadsError()
ObjectAlreadyExistsError
Thrown when trying to access a file with an ID that doesn’t exist.
Usage
ObjectAlreadyExistsError()
ObjectError
Generic base exception for error that occur while handling file objects.
Usage
ObjectError()
ObjectIdValidationError
Thrown when an object ID is not valid.
Usage
ObjectIdValidationError()
ObjectNotFoundError
Thrown when trying to access a bucket with an ID that doesn’t exist.
Usage
ObjectNotFoundError()
ObjectStorageProtocolError
Generic base exception for all custom errors used by this protocol.
Usage
ObjectStorageProtocolError()Methods
| Name | Description |
|---|---|
| abort_multipart_upload() | Cancel a multipart upload with the specified ID. All uploaded content is |
| complete_multipart_upload() | Completes a multipart upload with the specified ID. In addition to the |
| copy_object() |
Copy an object from one bucket (source_bucket_id and source_object_id) to
|
| create_bucket() | Create a bucket (= a structure that can hold multiple file objects) with the |
| delete_bucket() | Delete a bucket (= a structure that can hold multiple file objects) with the |
| delete_object() |
Delete an object with the specified id (object_id) in the bucket with the
|
| does_bucket_exist() |
Check whether a bucket with the specified ID (bucket_id) exists.
|
| does_object_exist() |
Check whether an object with specified ID (object_id) exists in the bucket
|
| get_all_multipart_uploads() | Gets all active multipart uploads for the given bucket ID. |
| get_object_download_url() | Generates and returns a presigned HTTP-URL to download a file object with |
| get_object_etag() | Returns the etag of an object. |
| get_object_metadata() | Returns object metadata without downloading the actual object. |
| get_object_size() | Returns the size of an object in bytes. |
| get_object_upload_url() | Generates and returns an HTTP URL to upload a new file object with the given |
| get_part_upload_url() | Given a id of an instantiated multipart upload along with the corresponding |
| init_multipart_upload() | Initiates a multipart upload procedure. Returns the upload ID. |
| list_all_object_ids() | Retrieve a list of IDs for all objects currently present in the specified bucket |
| list_multipart_uploads_for_object() | Lists all active multipart uploads for the given object ID. |
| list_parts() | Lists the parts that have been uploaded for a specific multipart upload. |
abort_multipart_upload()
Cancel a multipart upload with the specified ID. All uploaded content is
Usage
abort_multipart_upload(*, upload_id, bucket_id, object_id)deleted.
complete_multipart_upload()
Completes a multipart upload with the specified ID. In addition to the
Usage
complete_multipart_upload(
*,
upload_id,
bucket_id,
object_id,
anticipated_part_quantity=None,
anticipated_part_size=None
)corresponding bucket and object id, you also specify an anticipated part size and an anticipated part quantity. This ensures that exactly the specified number of parts exist and that all parts (except the last one) have the specified size.
copy_object()
Copy an object from one bucket (source_bucket_id and source_object_id) to
Usage
copy_object(
*,
source_bucket_id,
source_object_id,
dest_bucket_id,
dest_object_id,
abort_failed=True
)another bucket (dest_bucket_id and dest_object_id).
If abort_failed is set to true (default), a failed copy operation tries to abort the ongoing multipart upload it created (if using multipart mode). This only works reliably as long as there are no other ongoing multipart operations for the same destination bucket and object ID, in which case this should be set to false.
create_bucket()
Create a bucket (= a structure that can hold multiple file objects) with the
Usage
create_bucket(bucket_id)specified unique ID.
delete_bucket()
Delete a bucket (= a structure that can hold multiple file objects) with the
Usage
delete_bucket(bucket_id, *, delete_content=False)specified unique ID. If delete_content is set to True, any contained objects will be deleted, if False (the default) a BucketNotEmptyError will be raised if the bucket is not empty.
delete_object()
Delete an object with the specified id (object_id) in the bucket with the
Usage
delete_object(*, bucket_id, object_id)specified id (bucket_id).
Deleting an object that does not exist succeeds silently. However, a BucketNotFoundError is raised if the bucket does not exist.
does_bucket_exist()
Check whether a bucket with the specified ID (bucket_id) exists.
Usage
does_bucket_exist(bucket_id)Returns True if it exists and False otherwise.
does_object_exist()
Check whether an object with specified ID (object_id) exists in the bucket
Usage
does_object_exist(*, bucket_id, object_id, object_md5sum=None)with the specified id (bucket_id). Optionally, a md5 checksum (object_md5sum) may be provided to check the objects content. Returns True if checks succeed and False otherwise.
get_all_multipart_uploads()
Gets all active multipart uploads for the given bucket ID.
Usage
get_all_multipart_uploads(*, bucket_id)Returns a dict where the keys are upload IDs and values are object IDs. S3 allows multiple ongoing multi-part uploads, so it’s possible for some upload IDs to map to the same object ID.
Raises a BucketNotFoundError if the bucket does not exist.
get_object_download_url()
Generates and returns a presigned HTTP-URL to download a file object with
Usage
get_object_download_url(*, bucket_id, object_id, expires_after=86400)the specified ID (object_id) from bucket with the specified id (bucket_id). You may also specify a custom expiry duration in seconds (expires_after).
get_object_etag()
Returns the etag of an object.
Usage
get_object_etag(*, bucket_id, object_id)
get_object_metadata()
Returns object metadata without downloading the actual object.
Usage
get_object_metadata(*, bucket_id, object_id)
get_object_size()
Returns the size of an object in bytes.
Usage
get_object_size(*, bucket_id, object_id)
get_object_upload_url()
Generates and returns an HTTP URL to upload a new file object with the given
Usage
get_object_upload_url(
*,
bucket_id,
object_id,
expires_after=DEFAULT_URL_EXPIRATION_PERIOD,
max_upload_size=None
)id (object_id) to the bucket with the specified id (bucket_id). You may also specify a custom expiry duration in seconds (expires_after) and a maximum size (bytes) for uploads (max_upload_size).
get_part_upload_url()
Given a id of an instantiated multipart upload along with the corresponding
Usage
get_part_upload_url(
*,
upload_id,
bucket_id,
object_id,
part_number,
expires_after=3600,
part_md5=None
)bucket and object ID, it returns a presigned URL for uploading a file part with the specified number. Please note: the part number must be a non-zero, positive integer and parts should be uploaded in sequence.
init_multipart_upload()
Initiates a multipart upload procedure. Returns the upload ID.
Usage
init_multipart_upload(*, bucket_id, object_id)
list_all_object_ids()
Retrieve a list of IDs for all objects currently present in the specified bucket
Usage
list_all_object_ids(bucket_id)
list_multipart_uploads_for_object()
Lists all active multipart uploads for the given object ID.
Usage
list_multipart_uploads_for_object(*, bucket_id, object_id)Raises a BucketNotFoundError if the bucket does not exist.
list_parts()
Lists the parts that have been uploaded for a specific multipart upload.
Usage
list_parts(
*, bucket_id, object_id, upload_id, max_parts=None, first_part_no=None
)Specify max_parts to return a limited parts list. If not specified, all parts will be returned (up to 10,000).
Specify first_part_no to get parts starting with that part number. If not specified, retrieved parts will start with the first part. Part numbers start at 1, not 0.
Raises
ValueError-
if
max_partsorfirst_part_noare invalid. MultiPartUploadNotFoundError-
if no upload with
upload_idexists.