Updated on 2022-02-10 GMT+08:00

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

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

String

Mandatory

Bucket name

Key

String

Mandatory

Object name

RequestDate

String

or

Date

Optional

Request time

NOTE:

When the parameter type is String, the value must comply with the ISO8601 or RFC822 standards.

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 range of the source object. 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 the target part in SSE-C mode. The value can be:

  • AES256

SseCKey

String

Optional

Key used to encrypt the target part in SSE-C mode. It is calculated by using AES-256.

CopySourceSseC

String

Optional

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

  • AES256

CopySourceSseCKey

String

Optional

Key used to decrypt the source object in SSE-C mode, which is calculated by using AES-256

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

Sample Code

obsClient.copyPart({
       Bucket:'bucketname',
       Key : 'objectkey',
       PartNumber : 1,
       UploadId : 'uploadid',
       CopySource : 'sourcebucketname/sourceobjectkey',
       CopySourceRange : 'bytes=0-10'
},function (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);
              }
       }
});