• Object Storage Service

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

Complete Multipart Upload

API Description

You can use this API to combine the uploaded parts in a specified bucket by using the multipart upload ID.

Method Definition

ObsClient.completeMultipartUpload(bucketName, objectKey, uploadId, completeMultipartUploadRequest)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

uploadId

str

Mandatory

Multipart upload ID

completeMultipartUploadRequest

CompleteMultipartUploadRequest

Mandatory

Request parameter of Complete Multipart Upload

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

CompleteMultipartUploadResponse

Response result of Complete Multipart Upload

Sample Code

try:
    from com.obs.models.complete_multipart_upload_request import CompleteMultipartUploadRequest, CompletePart 
      
    part1 = CompletePart(partNum=1, etag='etag1') 
    part2 = CompletePart(partNum=2, etag='etag2') 
      
    completeMultipartUploadRequest = CompleteMultipartUploadRequest(parts=[part1, part2]) 
      
    resp = obsClient.completeMultipartUpload('bucketname', 'objectkey', 'uploadid', completeMultipartUploadRequest) 
        
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('etag:', resp.body.etag) 
        print('bucket:', resp.body.bucket) 
        print('key:', resp.body.key) 
        print('location:', resp.body.location) 
        print('versionId:', resp.body.versionId) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())