Upload Part - Copy¶
After initiating a multipart upload, you can send an Upload Part request to upload parts for the multipart upload using its uploadId. The Upload Part - Copy operation allows you to upload a part by copying data from an existing object as data source.
This operation makes server-side encryption available.
Important
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 Cold Objects¶
If source objects are OBS cold objects, check the restore status of the objects. You can copy the OBS cold 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
User-Agent: agent
Host: bucketname.obs.example.com
Accept: */*
Date: date
x-amz-copy-source: sourceobject
x-amz-copy-source-range:bytes=start-end
Authorization: auth
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.
Parameter | Description | Remarks |
---|---|---|
partNumber | Indicates the number that identifies a part to be uploaded. Type: Integer | Mandatory |
uploadId | Indicates the ID of a multipart upload. Type: String | Mandatory |
Request Headers¶
This request uses headers listed in Table 2 in addition to common headers.
Header | Description | Remarks |
---|---|---|
x-amz-copy-source | Indicates the source object to be copied. Type: String | Mandatory |
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. | No. This header is mandatory 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 or 512-bit key and must be used together with x-amz-server-side-encryption-customer-algorithm and x-amz-server-side-encryption-customer-key-MD5. | No. This header is mandatory 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. | No. This header is mandatory 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. | No. This header is mandatory when SSE-C is used to copy a source object. |
x-amz-copy-source-server-side-encryption-customer-key | Indicates the customer-provided key used to decrypt the source object when customer-provided keys are used. 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 or 512-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-key-MD5. | No. This header is mandatory when customer-provided keys are used to copy source objects. |
x-amz-copy-source-server-side-encryption-customer-key-MD5 | Indicates the MD5 value of the customer-provided key used to decrypt the source object when customer-provided keys are used. 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. | No. This header is mandatory when customer-provided keys are used to copy source objects. |
x-amz-security-token | Header field used to identify the request of a federated user. When the federal authentication function is enabled, users sending such requests are identified as federated users. Type: string | Optional. This parameter must be carried in the request sent by federated users. |
Request Elements¶
This request involves no elements.
Response Syntax¶
HTTP/1.1 status_code
x-amz-id-2: id
x-amz-request-id: request id
x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc
Content-Type: type
Date: date
Server: server
Transfer-Encoding: chunked
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CopyPartResult xmlns="http://obs.example.com/doc/2015-06-30/">
<LastModified>modifiedDate</LastModified>
<ETag>etagValue</ETag>
</CopyPartResult>
Response Headers¶
This response uses common headers. For details about common response headers, see section Common 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.
Element | Description |
---|---|
LastModified | Indicates the date the part was last modified. Type: String |
ETag | Indicates the ETag of the source part. Type: String |
Error Responses¶
If an AccessKey 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 READ permission for the requested bucket, OBS returns status code 403 Forbidden and error code AccessDenied.
If the requester does not have 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.
Sample Request¶
PUT /newobject?partNumber=1&uploadId=VCVsb2FkIElEIGZvciBlbZZpbmcncyBteS1tb3ZpZS5tMnRzIHVwbG9hZR HTTP/1.1
User-Agent: Jakarta Commons-HttpClient/3.1
Host: bucketname.obs.example.com
Accept: */*
Date: Mon, 11 Apr 2011 20:34:56 GMT
x-amz-copy-source: /source-bucket/sourceobject
x-amz-copy-source-range:bytes=500-6291456
Authorization: AWS AKIAIOSFODNN7EXAMPLE:VGhpcyBtZXNzYWdlIHNpZ25lZGGieSRlbHZpbmc=
Content-Length: 5120
Sample Response¶
HTTP/1.1 200 OK
Server: OBS
x-amz-id-2: Vvag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==
x-amz-request-id: 656c76696e6727732072657175657374
x-reserved: amazon, aws and amazon web services are trademarks or registered trademarks of Amazon Technologies, Inc
Content-Type: application/xml
Date: Mon, 11 Apr 2011 20:34:56 GMT
Transfer-Encoding: chunked
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CopyPartResult xmlns="http://obs.example.com/doc/2015-06-30/">
<LastModified>2009-10-28T22:32:00</LastModified> <ETag>"9b2cf535f27731c974343645a3985328"</ETag>
</CopyPartResult>