Upload Manager

class oci.object_storage.UploadManager(object_storage_client, **kwargs)
__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.

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 None

Return type:

Response

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.
  • metadata (optional) (dict) -- A dictionary of string to string values to associate with the object to upload
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 the Response will contain the opc-multipart-md5 header and for a non-multipart upload it will contain the opc-content-md5 header.

Return type:

Response

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.

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.
  • metadata (optional) (dict) -- A dictionary of string to string values to associate with the object to upload
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) the Response will contain the opc-multipart-md5 header and for a non-multipart upload (empty stream data) it will contain the opc-content-md5 header.

Return type:

Response