Complete Multipart Upload

After uploading all parts for a multipart upload, you can use this operation to complete the multipart upload.

Upon receiving a Complete Multipart Upload request, OBS concatenates the uploaded parts to create a new object. All associated parts cannot be downloaded until the multipart upload is complete.

When starting to complete a multipart upload, OBS first copies the header information from the metadata of associated parts and then incorporates the header information into the metadata of the newly created object. If OBS completes several multipart uploads for creating namesake objects, it follows the Last Write Win policy. This means that only the last created object is retained.

Before a multipart upload is completed, all associated parts occupy storage quota. After the multipart upload is completed, only parts included in the part list specified in the Complete Multipart Upload request are concatenated. These parts still occupy storage quota while other parts are deleted to release storage quota.

After a multipart upload is completed, you can send a GET request to obtain the newly created object or some parts comprising this object by specifying a range in the request. You can also send a DELETE request to delete all parts uploaded for the multipart upload. The deleted parts cannot be restored.

The Etag of an object with combined parts is not the real MD5 value of the object. The object ETag is calculated as follows: MD5(M1M2......MN)-N, where Mn is the MD5 value of part N (N is the total number of parts). As described in the example below, there are three parts and each part has an MD5. The MD5 values of the three parts are combined and recalculated to obtain a new MD5 value. Then -N, as ETag of the combined part, is added to the right of the MD5 value. (N indicates the number of parts and is 3 in the example.)

Versioning

If a bucket has versioning enabled, a unique version ID is generated for an object created from a multipart upload in this bucket and the version ID is returned in response header x-amz-version-id. If the bucket has versioning suspended, the version ID of the object is null. For details about bucket versioning, see PUT Bucket Versioning.

NOTICE:

If 10 parts are uploaded but only 9 parts are selected for combination, the part that is not combined will be automatically deleted. After the part is deleted, it cannot be restored. Before combining the parts, adopt the interface used to list the parts that have been uploaded to check all parts to ensure that no part is missed.

Request Syntax

POST /ObjectName?uploadId=uploadID HTTP/1.1
Host: bucketname.obs.cn-north-1.myhwclouds.com
Date: date
Content-Length: length
Authorization: authorization
<CompleteMultipartUpload>
    <Part>
        <PartNumber>partNum</PartNumber>
        <ETag>etag</ETag>
    </Part>
    <Part>
        <PartNumber>partNum</PartNumber>
        <ETag>etag</ETag>
    </Part>
    <Part>
        <PartNumber>partNum</PartNumber>
        <ETag>etag</ETag>
    </Part>
</CompleteMultipartUpload>

Request Parameters

This request uses one parameter to specify the ID of the multipart upload to be completed. Table 1 describes the parameter.

Table 1 Request parameter

Parameter

Description

Required or Optional

uploadId

Indicates the ID of the multipart upload to be completed.

Type: string

Required

Request Headers

This request uses common headers. For details about common request headers, see Common Request Headers.

Request Elements

This request contains elements to specify the part list for the multipart upload to be completed. Table 2 describes the elements.

Table 2 Request elements

Element

Description

Required or Optional

CompleteMultipartUpload

Indicates the container for the list of parts to be concatenated.

Type: XML

Required

PartNumber

Indicates the number that identifies a part.

Type: integer

Required

ETag

Indicates the ETag returned after a part is uploaded.

Type: string

Required

Response Syntax

HTTP/1.1 status_code
Date: date
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CompleteMultipartUploadResult xmlns="http://obs.cn-north-1.myhwclouds.com/doc/2015-06-30/">
    <Location>http://example-Bucket.obs.cn-north-1.myhwclouds.com/example-Object</Location>
    <Bucket>bucketname</Bucket>
    <Key>ObjectName</Key>
    <ETag>ETag</ETag>
</CompleteMultipartUploadResult>

Response Headers

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

This response also uses additional headers, as described in Table 3.

Table 3 Additional response headers

Header

Description

x-amz-version-id

Indicates the version ID of the object created from a multipart upload.

Type: string

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

Response Elements

This response contains elements to indicate the results of completing a multipart upload. Table 4 describes the elements.

Table 4 Response elements

Element

Description

Location

Indicates the URL of the newly created object.

Type: string

Bucket

Indicates the bucket that contains the newly created object.

Type: string

Key

Indicates the key of the newly created object.

Type: string

ETag

Indicates the ETag that identifies the metadata of the newly created object. This ETag is calculated using the MD5 values of parts comprising the newly created object.

Type: string

Error Responses

If the request contains no request body, OBS returns status code 400 Bad Request.

If the request contains a request body in incorrect syntax, OBS returns status code 400 Bad Request.

If parts are not listed in the request body in ascending order, OBS returns status code 400 Bad Request and error code InvalidPartOrder.

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 multipart upload does not exist, OBS returns 404 NotFound 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 list contains nonexistent parts, OBS returns status code 400 Bad Request and error code InvalidPart.

If the ETag of a part in the part list is incorrect, OBS returns status code 400 Bad Request and error code InvalidPart.

If the size of a part (excluding the last part) in the part list is smaller than 5 MB, OBS returns status code 400 Bad Request.

If the size of the newly created object is greater than 48.8 TB, OBS returns status code 400 Bad Request.

For details about other error responses, see Table 1.

Example Request for Getting an Object Created from a Multipart Upload with Version ID Specified

POST /multi?uploadId=DCD2FC9CAB7800000143947AB58A5094 HTTP/1.1
Host: bucketname.obs.cn-north-1.myhwclouds.com
Date: Wed, 15 Jan 2014 06:09:39 +0000
Authorization: AWS C9590CEB8EC051BDEC9D:xQ9EFib6cohqMu2bLLJ0soseeUI=
Content-Length: 155

<CompleteMultipartUpload>
    <Part>
        <PartNumber>1</PartNumber>
        <ETag>"9fd2e548507ceef1a2183a8328b5cf2c"</ETag>
    </Part>
</CompleteMultipartUpload>
Registration