Copying Parts
Functions
After a multipart upload task is created, you can upload parts for this task using the obtained multipart upload ID. For details about the multipart upload, see Multipart Upload. Alternatively, you can make an API call to copy a part or a whole uploaded object as a part.
This operation supports server-side encryption.

You cannot determine whether a request is successful only based on the status_code in the returned HTTP header. If 200 is returned for status_code, the server has received the request and started to process the request. The copy is successful only when the body in the response contains ETag.
Copy the source object and save it as part1. If a part1 already exists before the copying, the original part1 will be overwritten by the newly copied part1. After the copy is successful, only the latest part1 is displayed. The old part1 data will be deleted. Therefore, ensure that the target part does not exist or has no value when using the part copy operation. Otherwise, data may be deleted by mistake. The source object in the copy process does not change.
Archive Objects
If source objects are in the Archive storage class, ensure that these objects have been restored before you copy them. If the source object is not restored or is 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.region.myhuaweicloud.com Date: date x-obs-copy-source: sourceobject x-obs-copy-source-range:bytes=start-end Authorization: authorization Content-Length: length
Request Parameters
To copy a part, you need to specify the part number of the target part and the multipart upload task number. Table 1 describes the parameters.
Parameter |
Mandatory (Yes/No) |
Type |
Description |
---|---|---|---|
partNumber |
Yes |
Integer |
Definition: Indicates the ID of a part to be uploaded. Constraints: None Range: An integer ranging from 1 to 10000. Default value: None |
uploadId |
Yes |
String |
Definition: ID of a multipart upload task. Constraints: None Range: The value must contain 1 to 32 characters. Default value: None |
Request Headers
In addition to the common message headers, the request uses two extended headers. Table 2 describes the common message headers.
Parameter |
Mandatory (Yes/No) |
Type |
Description |
---|---|---|---|
x-obs-copy-source |
Yes |
String |
Definition: Indicates the source object to be copied. Example: x-obs-copy-source:/SourceBucketName/SourceObjectName Constraints: Full-width characters and percent signs (%) must be URL-encoded. Range: None Default value: None |
x-obs-copy-source-range |
No |
Integer |
Definition: Byte range of the part to be copied in the source object. Constraints: None Range: The minimum value is 0 and the maximum value is the object length minus 1. Default value: None |
x-obs-server-side-encryption-customer-algorithm |
Yes only when SSE-C is used. The encryption algorithm must be the same as that used to initiate multipart upload tasks. |
String |
Definition: Indicates the encryption algorithm for the part copy when SSE-C is used. Example: x-obs-server-side-encryption-customer-algorithm:AES256 Constraints: This header must be used together with x-obs-server-side-encryption-customer-key and x-obs-server-side-encryption-customer-key-MD5. Range: AES256: SSE-C encryption and the AES256 algorithm are used. Default value: None |
x-obs-server-side-encryption-customer-key |
Yes only when SSE-C is used. The key must be the same as that used to initiate multipart upload tasks. |
String |
Definition: Indicates the key used to encrypt the target part when SSE-C is used. Example: x-obs-server-side-encryption-customer-key:K7QkYpBkM5+hca27fsNkUnNVaobncnLht/rCB2o/9Cw= Constraints: This header is a Base64-encoded 256-bit key and must be used together with x-obs-server-side-encryption-customer-algorithm and x-obs-server-side-encryption-customer-key-MD5. Range: None Default value: None |
x-obs-server-side-encryption-customer-key-MD5 |
Yes only when SSE-C is used. The MD5 value must be the same as that used to initiate multipart upload tasks. |
String |
Definition: Indicates the MD5 value of the key for encrypting the part when SSE-C is used. The MD5 value is used to ensure data integrity during key transmission. Example: x-obs-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-obs-server-side-encryption-customer-algorithm and x-obs-server-side-encryption-customer-key. Range: MD5 value of the key. Default value: None |
x-obs-copy-source-server-side-encryption-customer-algorithm |
Yes only when SSE-C is used to copy a source object |
String |
Definition: Indicates the encryption algorithm for the source object when SSE-C is used. Example: x-obs-copy-source-server-side-encryption-customer-algorithm:AES256 Constraints: This header must be used together with x-obs-copy-source-server-side-encryption-customer-key and x-obs-copy-source-server-side-encryption-customer-key-MD5. Range: AES256: SSE-C encryption and the AES256 algorithm are used. Default value: None |
x-obs-copy-source-server-side-encryption-customer-key |
Yes only when SSE-C is used to copy a source object |
String |
Definition: Indicates the key for decrypting the source object when SSE-C is used. Example: x-obs-copy-source-server-side-encryption-customer-key:K7QkYpBkM5+hca27fsNkUnNVaobncnLht/rCB2o/9Cw= Constraints: This header is a Base64-encoded 256-bit key and must be used together with x-obs-copy-source-server-side-encryption-customer-algorithm and x-obs-copy-source-server-side-encryption-customer-key-MD5. Range: None Default value: None |
x-obs-copy-source-server-side-encryption-customer-key-MD5 |
Yes only when SSE-C is used to copy a source object |
String |
Definition: Indicates the MD5 value of the key for the source object when SSE-C is used. The MD5 value is used to ensure data integrity during key transmission. Example: x-obs-copy-source-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-obs-copy-source-server-side-encryption-customer-algorithm and x-obs-copy-source-server-side-encryption-customer-key. Range: MD5 value of the key. Default value: None |
x-obs-copy-source-if-match |
No |
String |
Definition: Indicates that the source object is copied only if its ETag matches the one specified in this header. Otherwise, a 412 status code (failed precondition) is returned. Example: x-obs-copy-source-if-match: etag Constraints: This parameter can be used with x-obs-copy-source-if-unmodified-since but cannot with other conditional copy headers. Range: The ETag of the source object Default value: None |
x-obs-copy-source-if-none-match |
No |
String |
Definition: Indicates that the source object is copied only if its ETag does not match the one specified in this header. Otherwise, a 412 status code (failed precondition) is returned. Example: x-obs-copy-source-if-none-match: etag Constraints: This parameter can be used with x-obs-copy-source-if-modified-since but cannot with other conditional copy headers. Range: None Default value: None |
x-obs-copy-source-if-unmodified-since |
No |
String |
Definition: Objects are copied only if the source object has not been modified after the time specified by this parameter. Otherwise, error code 412 (the precondition is not met) is returned. Constraints:
Range: The value is an HTTP time character string in the format specified by RFC2616. Select one of the following formats:
Examples:
Default value: None |
x-obs-copy-source-if-modified-since |
No |
String |
Definition: Objects are copied only if the source object has been modified after the time specified by this parameter. Otherwise, error code 412 (the precondition is not met) is returned. Constraints:
Range: The value is an HTTP time character string in the format specified by RFC2616. Select one of the following formats:
Examples:
Default value: None |
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.region.myhuaweicloud.com/doc/2015-06-30/"> > <LastModified>modifiedDate</LastModified> <ETag>etag</ETag> </CopyPartResult>
Response Headers
The response to the request uses common headers. For details, see Table 1.
Parameter |
Type |
Description |
---|---|---|
x-obs-server-side-encryption |
String |
Definition: This parameter specifies the encryption mode for the part copy. Example: x-obs-server-side-encryption:kms Range:
|
x-obs-server-side-encryption-kms-key-id |
String |
Definition: If the SSE-KMS encryption is used with a specified key, the key ID is required. For details about how to obtain the key ID, see Viewing a Key. This header can be used to specify the encryption key only when the x-obs-server-side-encryption header is set to kms (that is, the KMS encryption is used). Range: If you choose to use KMS for encryption but do not set this header, the value of this header is the ID of the default key. If you want to use a custom key, obtain the key ID by referring to Viewing Key Details. |
x-obs-server-side-encryption-customer-algorithm |
String |
Definition: Indicates an encryption algorithm. This header is included in a response if SSE-C is used. Example: x-obs-server-side-encryption-customer-algorithm:AES256 Range: AES256: SSE-C encryption and the AES256 algorithm are used. |
x-obs-server-side-encryption-customer-key-MD5 |
String |
Definition: Indicates the MD5 value of the key for encrypting objects. This header is included in a response when SSE-C is used. Example: x-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ== Range: MD5 value of the key. |
Response Elements
This response contains elements of a part copy result. Table 4 describes the elements.
Parameter |
Type |
Description |
---|---|---|
LastModified |
String |
Definition: Indicates the latest time an object was modified. The time is in the ISO8601 format. Example: 2018-01-01T00:00:00.000Z Range: None |
ETag |
String |
Definition: ETag value of the target part. It is the unique identifier of the part content and is used to verify data integrity when assembling parts. Range: The value must contain 32 characters. |
Error Responses
- If the AK or signature is invalid, OBS returns 403 Forbidden and the error code is AccessDenied.
- Check whether the source bucket or destination bucket exists. If the source bucket or destination bucket does not exist, OBS returns 404 Not Found and the error code is NoSuchBucket.
- If the source object does not exist, OBS returns 404 Not Found and the error code is NoSuchKey.
- If the user does not have the read permission for the specified object, OBS returns 403 Forbidden and the error code is AccessDenied.
- If the user does not have the write permission for the destination bucket, OBS returns 403 Forbidden and the error code is AccessDenied.
- If the specified task does not exist, OBS returns 404 Not Found and the error code is NoSuchUpload.
- If the user is not the initiator of the multipart upload task, OBS returns 403 Forbidden and the error code is AccessDenied.
- When the size of a copied part has exceeded 5 GB, OBS returns 400 Bad Request.
- If a part number is not within the range from 1 to 10000, OBS returns error code 400 Bad Request.
Other errors are included in Table 2.
Sample Request
PUT /tobject02?partNumber=2&uploadId=00000163D40171ED8DF4050919BD02B8 HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 05:16:32 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:dSnpnNpawDSsLg/xXxaqFzrAmMw= x-obs-copy-source: /destbucket/object01
Sample Response
1 2 3 4 5 6 7 8 9 10 11 12 13 |
HTTP/1.1 200 OK Server: OBS x-obs-request-id: 8DF400000163D40ABBD20405D30B0542 x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTIJpD2efLy5o8sTTComwBb2He0j11Ne Content-Type: application/xml Date: WED, 01 Jul 2015 05:16:32 GMT Transfer-Encoding: chunked <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <CopyPartResult xmlns="http://obs.ap-southeast-1.myhuaweicloud.com/doc/2015-06-30/"> <LastModified>2015-07-01T05:16:32.344Z</LastModified> <ETag>"3b46eaf02d3b6b1206078bb86a7b7013"</ETag> </CopyPartResult> |
Sample Request: Specifying versionId to Copy a Part
PUT /tobject02?partNumber=2&uploadId=00000163D40171ED8DF4050919BD02B8 HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.myhuaweicloud.com Accept: */* Date: WED, 01 Jul 2015 05:16:32 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:dSnpnNpawDSsLg/xXxaqFzrAmMw= x-obs-copy-source: /examplebucket/object01?versionId=G001118A6456208AFFFFD24829FCF614
Sample Response: Specifying versionId to Copy a Part
HTTP/1.1 200 OK Server: OBS x-obs-request-id: 8DF400000163D40ABBD20405D30B0542 x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTIJpD2efLy5o8sTTComwBb2He0j11NeContent-Type: application/xml Date: WED, 01 Jul 2015 05:16:32 GMT Transfer-Encoding: chunked <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <CopyPartResult xmlns="http://obs.ap-southeast-1.myhuaweicloud.com/doc/2015-06-30/"> <LastModified>2015-07-01T05:16:32.344Z</LastModified> <ETag>"3b46eaf02d3b6b1206078bb86a7b7013"</ETag> </CopyPartResult>
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot