Updated on 2023-03-16 GMT+08:00

PUT Part - Copy

API Description

After the 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

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

Key

String

Mandatory

Object name

PartNumber

Number

Mandatory

Part number, which ranges from 1 to 10000

UploadId

String

Mandatory

Multipart upload ID

CopySource

String

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

String

Optional

Copy source range. The value range is [0, source object length-1] and is in the format of bytes=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.

SseC

String

Optional

Algorithm used to encrypt a target part in SSE-C mode. The value can be:

  • AES256

SseCKey

Buffer

Optional

Key used to encrypt a target part in SSE-C mode, which is calculated by using the AES256 algorithm.

CopySourceSseC

String

Optional

Algorithm used to decrypt a source object in SSE-C mode. The value can be:

  • AES256

CopySourceSseCKey

Buffer

Optional

Key used to decrypt a source object in SSE-C mode, which is calculated by using the AES256 algorithm.

Returned Result (InterfaceResult)

Field

Type

Description

RequestId

String

Request ID returned by the OBS server

ETag

String

ETag of the target part

LastModified

String

Time when the last modification was made to the target part

SseKms

String

Algorithm used in SSE-KMS encryption

SseKmsKey

String

Key used in SSE-KMS encryption

SseC

String

Algorithm used in SSE-C encryption

SseCKeyMd5

String

MD5 value of the key used in SSE-C encryption

Sample Code

obsClient.copyPart({
       Bucket:'bucketname',
       Key : 'objectkey',
       PartNumber : 1,
       UploadId : 'uploadid',
       CopySource : 'sourcebucketname/sourceobjectkey',
       CopySourceRange : 'bytes=0-10'
},(err, result) => {
       if(err){
              console.error('Error-->' + err);
       }else{
              if(result.CommonMsg.Status < 300){
                     console.log('RequestId-->' + result.InterfaceResult.RequestId);
                     console.log('LastModified-->' + result.InterfaceResult.LastModified);
                     console.log('ETag-->' + result.InterfaceResult.ETag);
              }else{
                     console.log('Code-->' + result.CommonMsg.Code);
                     console.log('Message-->' + result.CommonMsg.Message);
              }
       }
});