• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (Python SDK)
  4. Objects-Related APIs
  5. PUT Part - Copy

PUT Part - Copy

API Description

After a multipart upload is initialized, you can use this API to copy a part to a specified bucket by using the multipart upload ID.

Method Definition

ObsClient.copyPart(bucketName, objectKey, partNumber, uploadId, copySource, copySourceRange, destSseHeader, sourceSseHeader)

Request Parameter

Field

Type

Optional or Mandatory

Description

bucketName

str

Mandatory

Bucket name

objectKey

str

Mandatory

Object name

partNumber

int

Mandatory

Part number, which ranges from 1 to 10000

uploadId

str

Mandatory

Multipart upload ID

copySource

str

Mandatory

Parameter used to specify the source bucket, source object, and source object version ID which can be null. It is in the format of SourceBucketName/SourceObjectName?versionId=SourceObjectVersionId.

copySourceRange

str

Optional

Copy range of the source object. The value range is [0, source object length-1] and is in the format of x-y. If the maximum length of copySourceRange is larger than the length of the source object minus 1, the length of the source object minus 1 is used.

destSseHeader

SseCHeader

or

SseKmsHeader

Optional

Header for server-side encryption. It is used to encrypt the target object.

sourceSseHeader

SseCHeader

Optional

Header for server-side decryption. It is used to decrypt the source object.

Returned Result

Type

Description

GetResult

SDK common result object

GetResult.body Type

Description

CopyPartResponse

Response result of PUT Part - Copy

Sample Code

try:
    resp = obsClient.copyPart('bucketname', 'objectkey', 1, 'uploadid', 'sourcebucketname/sourceobjectkey', '0-15') 
    if resp.status < 300: 
        print('requestId:', resp.requestId) 
        print('etagValue:', resp.body.etagValue) 
        print('modifiedDate:', resp.body.modifiedDate) 
    else: 
        print('errorCode:', resp.errorCode) 
        print('errorMessage:', resp.errorMessage)
except:
    import traceback
    print(traceback.format_exc())