Upload Manager¶
-
class
oci.object_storage.
UploadManager
(object_storage_client, **kwargs)¶ Methods
__init__
(object_storage_client, **kwargs)UploadManager simplifies interaction with the Object Storage service by abstracting away the method used to upload objects. resume_upload_file
(namespace_name, …)Resume a multipart upload. upload_file
(namespace_name, bucket_name, …)Uploads an object to Object Storage. upload_stream
(namespace_name, bucket_name, …)Uploads streaming data to Object Storage. -
__init__
(object_storage_client, **kwargs)¶ UploadManager simplifies interaction with the Object Storage service by abstracting away the method used to upload objects. Depending on the configuration parameters, UploadManager may choose to do a single put_object request, or break up the upload into multiple parts and utilize multi-part uploads.
An advantage of using multi-part uploads is the ability to retry individual failed parts, as well as being able to upload parts in parallel to reduce upload time.
PLEASE NOTE that for oci versions < 2.23.2 and >= 2.18.0, timeout for the object storage client is overwritten to None for all operations which call object storage. For this reason, the operations are NOT thread-safe, and you should provide the UploadManager class with its own Object Storage client that isn’t used elsewhere. For more information please see Known Issues
Parameters: - object_storage_client (ObjectStorageClient) – A configured object storage client to use for interacting with the Object Storage service.
- allow_multipart_uploads (optional) (bool) – Whether or not this UploadManager supports performing mulitpart uploads. Defaults to True.
- allow_parallel_uploads (optional) (bool) – Whether or not this UploadManager supports uploading individual parts of a multipart upload in parallel. This setting has no effect on uploads that are performed using a single put_object call. Defaults to True.
- parallel_process_count (optional) (int) – The number of worker processes to use in parallel for uploading individual parts of a multipart upload. This setting is only used if allow_parallel_uploads is set to True. Defaults to 3.
-
resume_upload_file
(namespace_name, bucket_name, object_name, file_path, upload_id, **kwargs)¶ Resume a multipart upload.
Parameters: - namespace_name (str) – The namespace containing the bucket and multipart upload to resume.
- bucket_name (str) – The name of the bucket that contains the multipart upload to resume.
- object_name (str) – The name of the object in Object Storage.
- file_path – The path to the file to upload.
- upload_id (str) – The upload id for the multipart upload to resume.
- part_size (optional) (int) – Part size, in bytes, to use when resuming the transfer. The default is 128 mebibytes. If this value is supplied, it must be the same value as the one used when the original upload was started.
- progress_callback (optional) (function) – Callback function to receive the number of bytes uploaded since the last call to the callback function.
Returns: The response from the multipart commit operation. This will be a
Response
object with data of type NoneReturn type:
-
upload_file
(namespace_name, bucket_name, object_name, file_path, **kwargs)¶ Uploads an object to Object Storage. Depending on the options provided and the size of the object, the object may be uploaded in multiple parts.
Parameters: - namespace_name (str) – The namespace containing the bucket in which to store the object.
- bucket_name (str) – The name of the bucket in which to store the object.
- object_name (str) – The name of the object in Object Storage.
- file_path – The path to the file to upload.
- part_size (optional) (int) – Override the default part size of 128 MiB, value is in bytes.
- progress_callback (optional) (function) – Callback function to receive the number of bytes uploaded since the last call to the callback function.
- if_match (optional) (str) – The entity tag of the object to match.
- if_none_match (optional) (str) – The entity tag of the object to avoid matching. The only valid value is ‘*’, which indicates that the request should fail if the object already exists.
- content_md5 (str) – (optional) The base-64 encoded MD5 hash of the body. This parameter is only used if the object is uploaded in a single part.
- content_type (optional) (str) – The content type of the object to upload.
- content_language (optional) (str) – The content language of the object to upload.
- content_encoding (optional) (str) – The content encoding of the object to upload.
- content_disposition (optional) (str) – The content disposition of the object to upload.
- cache_control (optional) (str) – The cache control for the object to upload.
- metadata (optional) (dict) – A dictionary of string to string values to associate with the object to upload
- storage_tier (str) –
(optional) The storage tier that the object should be stored in. If not specified, the object will be stored in the same storage tier as the bucket.
Allowed values are: “Standard”, “InfrequentAccess”, “Archive”
Returns: The response from multipart commit operation or the put operation. In both cases this will be a
Response
object with data of type None. For a multipart upload theResponse
will contain theopc-multipart-md5
header and for a non-multipart upload it will contain theopc-content-md5 header
.Return type:
-
upload_stream
(namespace_name, bucket_name, object_name, stream_ref, **kwargs)¶ Uploads streaming data to Object Storage. If the stream is non-empty, this will always perform a multipart upload, splitting parts based on the part size (10 MiB if none specified). If the stream is empty, this will upload a single empty object to Object Storage.
Stream uploads are not currently resumable.
PLEASE NOTE that for oci versions < 2.53.1, this operation potentially causes data corruption. For more information, please see this github issue
Parameters: - namespace_name (str) – The namespace containing the bucket in which to store the object.
- bucket_name (str) – The name of the bucket in which to store the object.
- object_name (str) – The name of the object in Object Storage.
- stream_ref – The stream to read data from.
- part_size (optional) (int) – Override the default streaming part size of 10 MiB, value is in bytes.
- progress_callback (optional) (function) – Callback function to receive the number of bytes uploaded since the last call to the callback function.
- if_match (optional) (str) – The entity tag of the object to match.
- if_none_match (optional) (str) – The entity tag of the object to avoid matching. The only valid value is ‘*’, which indicates that the request should fail if the object already exists.
- content_type (optional) (str) – The content type of the object to upload.
- content_language (optional) (str) – The content language of the object to upload.
- content_encoding (optional) (str) – The content encoding of the object to upload.
- content_disposition (optional) (str) – The content disposition of the object to upload.
- cache_control (optional) (str) – The cache control for the object to upload.
- metadata (optional) (dict) – A dictionary of string to string values to associate with the object to upload
- storage_tier (str) –
(optional) The storage tier that the object should be stored in. If not specified, the object will be stored in the same storage tier as the bucket.
Allowed values are: “Standard”, “InfrequentAccess”, “Archive”
Returns: The response from multipart commit operation or the put operation. In both cases this will be a
Response
object with data of type None. For a multipart upload (non-empty stream data) theResponse
will contain theopc-multipart-md5
header and for a non-multipart upload (empty stream data) it will contain theopc-content-md5 header
.Return type:
-