• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Objects-Related APIs
  5. Initiate Multipart Upload

Initiate Multipart Upload

API Description

You can use this API to initialize a multipart upload in a specified bucket.

Method Definition

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

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

acl

str

Optional

Pre-defined access policy. Possible values are:

  • private
  • public-read
  • public-read-write
  • authenticated-read
  • bucket-owner-read
  • bucket-owner-full-control

storageClass

str

Optional

Storage class of the object. Possible values are:

  • STANDARD
  • STANDARD_IA
  • GLACIER

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

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

InitiateMultipartUploadResponse

Response result of Initiate 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())