Initializing a Multipart Upload

API Description

You can use this API to initialize a multipart upload in a specified bucket. After a multipart upload is initialized, an upload ID created by the OBS server is returned to identify the multipart upload. You can use this upload ID to initiate related operations, such as aborting a multipart upload, listing multipart uploads, and listing uploaded parts.

Method Definition

ObsClient.initiateMultipartUpload(bucketName, objectKey, acl, storageClass, metadata, websiteRedirectLocation, contentType, sseHeader, expires, extensionGrants)

Request Parameters

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

acl

str

Optional

Pre-defined Access Control Policies

storageClass

str

Optional

Storage class of the object

metadata

dict

Optional

Customized metadata of the object

websiteRedirectLocation

str

Optional

Location where the object is redirected to, when the bucket is configured with website hosting.

contentType

str

Optional

MIME type of the object

sseHeader

SseCHeader

or

SseKmsHeader

Optional

Header for server-side encryption

expires

int

Optional

Expiration time of the object, in days

extensionGrants

list of ExtensionGrant

Optional

Extended permission list of the object

Returned Results

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

InitiateMultipartUploadResponse

Response result of the request for initializing a multipart upload

Sample Code

try:
    resp = obsClient.initiateMultipartUpload('bucketname', 'objectkey', contentType='text/plain') 
      
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('bucketName:', resp.body.bucketName) 
        print('objectKey:', resp.body.objectKey) 
        print('uploadId:', resp.body.uploadId) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())