Upload Part - Copy

After creating a multipart upload job, you can specify its upload ID and upload a part to the job in OBS. Alternatively, you can call this API to add a part (part of an object or the whole object).

This operation supports server-side encryption.

NOTICE:

You cannot determine whether a request is executed successfully only using status_code in the header returned by HTTP.

If 200 in status_code is returned, the server has received the request and starts to process the request from the upload part. The body in the response shows whether the upload operation succeeds. The upload operation succeeds only when the body has ETags. Otherwise, the upload operation fails.

Copy the source object as part1. If part1 already exists before you copy the source object, the old part1 will be overwritten by the new part1.

After the source object is copied, only the latest part1 is listed. The old part1 will be deleted. Before using the copy interface, ensure that the target part does not exist or is useless to avoid incorrect data deletion.

During the copy process, the source object is not changed.

OBS Archive Objects

If source objects are OBS Archive objects, check the restore status of the objects. You can copy the OBS Archive objects only after the objects are restored. If the objects are not restored or are being restored, the copy fails, and error "403 Forbidden" is returned. The fault is described as follows:

ErrorCode: InvalidObjectState

ErrorMessage: Operation is not valid for the source object's storage class

Request Syntax

PUT /ObjectName?partNumber=partNum&uploadId=UploadID HTTP/1.1
Host: bucketname.obs.cn-north-1.myhwclouds.com
Date: date
x-amz-copy-source: sourceobject
x-amz-copy-source-range:bytes=start-end
Authorization: authorization
Content-Length: length

Request Parameters

This request uses parameters to specify the ID of a multipart upload and part number. Table 1 describes the parameters.

Table 1 Request parameters

Parameter

Description

Required or Optional

partNumber

Indicates the number that identifies a part to be uploaded.

Type: integer

Required

uploadId

Indicates the ID of a multipart upload.

Type: string

Required

Request Headers

This request uses headers listed in Common Request Headers in addition to common headers.

Table 2 Request headers

Header

Description

Required or Optional

x-amz-copy-source

Indicates the source object to be copied.

Type: string

Required

x-amz-copy-source-range

Indicates the range of bytes (start - end) to be copied from the source object. start indicates the start byte of the part to be copied and end indicates the end byte.

Type: integer

Optional

x-amz-server-side-encryption-customer-algorithm

Indicates an algorithm used to encrypt a destination part. The header is used in SSE-C mode.

Type: string

Example: x-amz-server-side-encryption-customer-algorithm:AES256

Constraints: This header must be used together with x-amz-server-side-encryption-customer-key and x-amz-server-side-encryption-customer-key-MD5.

Optional. This header is required when SSE-C is used. The encryption algorithm must be the same as the algorithm used to initiate multipart upload tasks.

x-amz-server-side-encryption-customer-key

Indicates a key used to encrypt a destination part. The header is used in SSE-C mode.

Type: string

Example: x-amz-server-side-encryption-customer-key:K7QkYpBkM5+hcs27fsNkUnNVaobncnLht/rCB2o/9Cw=

Constraints: This header is a base64-encoded 256-bit key and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key-MD5.

Optional. This header is required when SSE-C is used. The key must be the same as that used to initiate multipart upload tasks.

x-amz-server-side-encryption-customer-key-MD5

Indicates the MD5 value of a key used to encrypt a destination part. The header is used in SSE-C mode. The MD5 value is used to check whether any error occurs during the transmission of the key.

Type: string

Example: x-amz-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Constraints: This header is a base64-encoded 128-bit MD5 value and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key.

Optional. This header is required when SSE-C is used. The MD5 value must be the same as that used to initiate multipart upload tasks.

x-amz-copy-source-server-side-encryption-customer-algorithm

Indicates an algorithm used by a source object. The header is used in SSE-C mode.

Type: string

Example: x-amz-copy-source-server-side-encryption-customer-algorithm:AES256

Constraints: This header must be used together with x-amz-copy-source-server-side-encryption-customer-key and x-amz-copy-source-server-side-encryption-customer-key-MD5.

Optional. This header is required when SSE-C is used to copy a source object.

x-amz-copy-source-server-side-encryption-customer-key

Indicates the algorithm used to decrypt the source object. The header is used in SSE-C mode.

Type: string

Example: x-amz-copy-source-server-side-encryption-customer-key:K7QkYpBkM5+hcs27fsNkUnNVaobncnLht/rCB2o/9Cw=

Constraints: This header is a base64-encoded 256-bit key and must be used together with x-amz-copy-source-server-side-encryption-customer-algorithm and x-amz-copy-source-server-side-encryption-customer-ey-MD5.

Optional. This header is required when SSE-C is used to copy a source object.

x-amz-copy-source-server-side-encryption-customer-key-MD5

Indicates the MD5 value of the key used for the source object. The header is used in SSE-C mode. The MD5 value is used to check whether any error occurs during the transmission of the key.

Type: string

Example: x-amz-copy-source-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Constraints: This header is a 128-bit base64-encoded string and must be used together with x-amz-copy-source-server-side-encryption-customer-algorithm and x-amz-copy-source-server-side-encryption-customer-key.

Optional. This header is required when SSE-C is used to copy a source object.

Request Elements

This request involves no elements.

Response Syntax

HTTP/1.1 status_code
Date: date

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CopyPartResult xmlns="http://obs.cn-north-1.myhwclouds.com/doc/2015-06-30/">
    <LastModified>modifiedDate</LastModified> 
    <ETag>etag</ETag>
</CopyPartResult> 

Response Headers

This response uses common headers. For details about common response headers, see Common Response Headers.

Table 3 Response headers

Header

Description

x-amz-server-side-encryption

This header is included in a response if SSE-KMS is used.

Type: string

Example: x-amz-server-side-encryption:aws:kms

x-amz-server-side-encryption-aws-kms-key-id

Indicates the master key ID. This header is included in a response if SSE-KMS is used.

Example: x-amz-server-side-encryption-aws-kms-key-id:arn:aws:kms:sichuan:domainiddomainiddomainiddoma0001:key/4f1cd4de-ab64-4807-920a-47fc42e7f0d0

x-amz-server-side-encryption-customer-algorithm

Indicates an encryption algorithm. This header is included in a response if SSE-C is used.

Type: string

Example: x-amz-server-side-encryption-customer-algorithm:AES256

x-amz-server-side-encryption-customer-key-MD5

Indicates the MD5 value of a key used to encrypt objects. This header is included in a response if SSE-C is used.

Type: string

Example: x-amz-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ==

Response Elements

This response contains elements to indicate the copy results. Table 4 describes the elements.

Table 4 Response elements

Element

Description

LastModified

Indicates the date the part was last modified.

Type: string

ETag

Indicates the ETag of the target part.

Type: string

Error Responses

  • If an AK or signature is invalid, OBS returns status code 403 Forbidden and error code AccessDenied.
  • If the requested bucket does not exist, OBS returns status code 404 Not Found and error code NoSuchBucket.
  • If the requested source object does not exist, OBS returns status code 404 Not Found and error code NoSuchKey.
  • If the requester does not have the READ permission for the requested bucket, OBS returns status code 403 Forbidden and error code AccessDenied.
  • If the requester does not have the WRITE permission for the requested bucket, OBS returns status code 403 Forbidden and error code AccessDenied.
  • If the requested multipart upload does not exist, OBS returns status code 404 Not Found and error code NoSuchUpload.
  • If the requester is not the initiator of the multipart upload, OBS returns status code 403 Forbidden and error code AccessDenied.
  • If the part size is greater than 5 GB, OBS returns status code 400 Bad Request.
  • If the part number exceeds the range of 1 to 10,000, OBS returns status code 400 Bad Request.

For details about other error responses, see Table 1.

Registration