• Object Storage Service

obs
  1. Help Center
  2. Object Storage Service
  3. API Reference (PHP 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

1. ObsClient->copyPart(array $parameter)
2. ObsClient->copyPartAsync(array $parameter, callable $callback)

Request Parameter

Field

Type

Optional or Mandatory

Description

Bucket

string

Mandatory

Bucket name

Key

string

Mandatory

Object name

PartNumber

integer

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

Field

Type

Description

HttpStatusCode

integer

HTTP status code

Reason

string

Reason 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

try {
       $resp = $obsClient->copyPart( [ 
              'Bucket' => 'bucketname',
              'Key' => 'objectkey',
              'UploadId' => 'uploadid',
              'PartNumber' => 1,
              'CopySource' => 'sourcebucketname/sourceobjectkey',
              'CopySourceRange' => 'bytes=0-10'
       ] );
       printf ( "RequestId:%s\n", $resp ['RequestId'] );
       printf ( "ETag:%s\n", $resp ['ETag'] );
       printf ( "LastModified:%s\n", $resp ['LastModified'] );
} catch ( Obs\Common\ObsException $obsException ) {
       printf ( "ExceptionCode:%s\n", $obsException->getExceptionCode () );
       printf ( "ExceptionMessage:%s\n", $obsException->getExceptionMessage () );
}