After creating a multipart upload job, you can specify its upload ID and upload a part to the job in OBS. Alternatively, you can make an API call to add a part (part of an object or the whole object).
This operation supports server-side encryption.
You cannot determine whether a request is executed successfully only using status_code in the returned HTTP header. If 200 in status_code is returned, the server has received the request and starts to process the request. The body in the response shows whether the request is executed successfully. The request is executed successfully only when the body contains Etag; otherwise, the request fails to be executed.
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.
If source objects are in the Cold 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
PUT /ObjectName?partNumber=partNum&uploadId=UploadID HTTP/1.1 Host: bucketname.obs.region.example.com Date: date x-obs-copy-source: sourceobject x-obs-copy-source-range:bytes=start-end Authorization: authorization Content-Length: length
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.
In addition the common message headers, the request uses two extended headers. Table 3 describes the common message header.
Header |
Description |
Mandatory |
---|---|---|
x-obs-copy-source |
Indicates the source object to be copied. Type: string |
Yes |
x-obs-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 |
No |
x-obs-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-obs-server-side-encryption-customer-algorithm:AES256 Constraint: This header must be used together with x-obs-server-side-encryption-customer-key and x-obs-server-side-encryption-customer-key-MD5. |
No. This header is required when SSE-C is used. The encryption algorithm must be the same as that used to initiate multipart upload tasks. |
x-obs-server-side-encryption-customer-key |
Indicates a key used to encrypt a destination part. The header is used in SSE-C mode. This key is used to encrypt objects. Type: string Example: x-obs-server-side-encryption-customer-key:K7QkYpBkM5+hca27fsNkUnNVaobncnLht/rCB2o/9Cw= Constraint: 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. |
No. This header is required when SSE-C is used. The key must be the same as that used to initiate multipart upload tasks. |
x-obs-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-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ== Constraint: 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. |
No. 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-obs-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-obs-copy-source-server-side-encryption-customer-algorithm:AES256 Constraint: 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. |
No. This header is required when SSE-C is used to copy a source object. |
x-obs-copy-source-server-side-encryption-customer-key |
Indicates the algorithm used to decrypt a source object. The header is used in SSE-C mode. Type: string Example: x-obs-copy-source-server-side-encryption-customer-key:K7QkYpBkM5+hca27fsNkUnNVaobncnLht/rCB2o/9Cw= Constraint: 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. |
No. This header is required when SSE-C is used to copy a source object. |
x-obs-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-obs-copy-source-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ== Constraint: 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. |
No. This header is required when SSE-C is used to copy a source object. |
This request involves no elements.
HTTP/1.1 status_code Date: date <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <CopyPartResult xmlns="http://obs.region.example.com/doc/2015-06-30/"> <LastModified>modifiedDate</LastModified> <ETag>etag</ETag> </CopyPartResult>
The response to the request uses common headers. For details, see Table 1.
Header |
Description |
---|---|
x-obs-server-side-encryption |
This header is included in a response if SSE-KMS is used. Type: string Example: x-obs-server-side-encryption:kms |
x-obs-server-side-encryption-kms-key-id |
Indicates the master key ID. This header is included in a response if SSE-KMS is used. Type: string Format: regionID:domainID:key/key_id regionID indicates the ID of the region where the key belongs. domainID indicates the ID of the tenant where the key belongs. key_id indicates the key ID used in this encryption. Example: x-obs-server-side-encryption-kms-key-id:region:domainiddomainiddomainiddoma0001:key/4f1cd4de-ab64-4807-920a-47fc42e7f0d0 |
x-obs-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-obs-server-side-encryption-customer-algorithm:AES256 |
x-obs-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-obs-server-side-encryption-customer-key-MD5:4XvB3tbNTN+tIEVa0/fGaQ== |
This response contains elements of a part copy result. Table 4 describes the elements.
Other errors are included in Table 2.
PUT /tobject02?partNumber=2&uploadId=00000163D40171ED8DF4050919BD02B8 HTTP/1.1 User-Agent: curl/7.29.0 Host: examplebucket.obs.region.example.com Accept: */* Date: WED, 01 Jul 2015 05:16:32 GMT Authorization: OBS H4IPJX0TQTHTHEBQQCEC:dSnpnNpawDSsLg/xXxaqFzrAmMw= x-obs-copy-source: /destbucket/object01
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.example.com/doc/2015-06-30/"> <LastModified>2015-07-01T05:16:32.344Z</LastModified> <ETag>"3b46eaf02d3b6b1206078bb86a7b7013"</ETag> </CopyPartResult> |