Completing Multipart Upload

Last Updated At: 2025-10-21 09:10:00

Description

The Complete Multipart Upload API is used to complete the entire multipart upload process. After all parts are uploaded by using the Upload Parts API, this API should be called to complete the multipart upload process of the entire file. When using this API, you should provide the PartNumber and ETag of each part in the request body to verify the accuracy of each part.
Since parts need to be merged after they are uploaded and merging takes a few minutes, COS immediately returns a 200 status code when merging begins. COS periodically returns space information to keep the connection alive until the merge is complete. COS returns the merged parts in the body.

  • When the uploaded part is less than 1MB, calling this API will return a 400 EntityTooSmall.
  • When the uploaded part numbers are not consecutive, calling this API will return 400 InvalidPart.
  • When the part information in the request body is not arranged in ascending order by sequence number, calling this API will return a 400 InvalidPartOrder.
  • When the UploadId does not exist, calling this API will return a 404 NoSuchUpload.

    Note:

    It is recommended to complete multipart uploads promptly or abort multipart uploads because being uploaded but unterminated parts will occupy storage space and incur storage fees.

Request

Request Example

POST /<ObjectKey>?uploadId=UploadId HTTP/1.1
Host: <BucketName-APPID>.<Endpoint>
Date: GMT Date
Content-length: Size
Authorization: Auth String

Note:

Authorization: Auth String (For details, please refer to section Request Signature).

Request Header

Common Headers

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

Non-common Headers

This request has no special request header information.

Request Body

The specific node content of the API request body is:

<CompleteMultipartUpload>
  <Part>
    <PartNumber>1</PartNumber>
    <ETag>"fc392a65890e447ff4e2d256489a9773"</ETag>
  </Part>
  <Part>
    <PartNumber>2</PartNumber>
    <ETag>"fc392a65890e447ff4e2d256489a9773"</ETag>
  </Part>
    ...
</CompleteMultipartUpload>

The data are as follows:

Node Name (Keyword) Parent Node Description Type Required
CompleteMultipartUpload No Information describing all aspects of this multipart upload Container Yes

Content of the Container node CompleteMultipartUpload:

Node Name (Keyword) Parent Node Description Type Required
Part CompleteMultipartUpload Information describing each part uploaded in this multipart upload Container Yes

Container node Part content:

Node Name (Keyword) Parent Node Description Type Required
PartNumber CompleteMultipartUpload.Part Part numbers Integer Yes
ETag CompleteMultipartUpload.Part MD5 checksum value of each block file String Yes

Response

Response Headers

Common Response Headers

This response uses common response headers. For details, see Public Response Header.

Response Body

The response body returns application/xml data. The following contains all the nodes:

<CompleteMultipartUploadResult>
    <Location>examplebucket-1250000000.cos.city.yfm4.fsphere.cn/ObjectName</Location>
    <Bucket>examplebucket-1250000000</Bucket>
    <Key>examplebucket</Key>
    <ETag>"3a0f1fd698c235af9cf098cb74aa25bc"</ETag>
</CompleteMultipartUploadResult>

The data are as follows:

Node Name (Keyword) Parent Node Description Type
CompleteMultipartUploadResult No Description of all returned information Container

Content of Container node CompleteMultipartUploadResult:

Node Name (Keyword) Parent Node Description Type
Location CompleteMultipartUploadResult The public access domain name for creating the object. URL
Bucket CompleteMultipartUploadResult The destination bucket for the multipart upload, consisting of a user-defined string concatenated with the system-generated appid numeric string, separated by a hyphen, such as: examplebucket-1250000000. String
Key CompleteMultipartUploadResult Object name. String
ETag CompleteMultipartUploadResult The unique tag value of the merged object, which is not the MD5 checksum of the object content and is only used to check the uniqueness of the object. String

Practical Case

Request

POST /exampleobject?uploadId=1484728886e63106e87d8207536ae8521c89c42a436fe23bb58854a7bb5e87b7d77d4ddc48 HTTP/1.1
Host: examplebucket-1250000000.cos.city.yfm4.fsphere.cn
Date: Wed,18 Jan 2017 16:17:03 GMT
Authorization: q-sign-algorithm=sha1&q-ak=AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&q-sign-time=1484729794;32557625794&q-key-time=1484729794;32557625794&q-header-list=host&q-url-param-list=uploadId&q-signature=23627c8fddb3823cce4257b33c663fd83f9f820d
Content-Length: 138

<CompleteMultipartUpload>
  <Part>
    <PartNumber>1</PartNumber>
    <ETag>"fc392a65890e447ff4e2d256489a9773"</ETag>
  </Part>
  <Part>
    <PartNumber>2</PartNumber>
    <ETag>"fc392a65890e447ff4e2d256489a9774"</ETag>
  </Part>
</CompleteMultipartUpload>

Response

HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: 277
Connection: keep-alive
Date: Wed,18 Jan 2017 16:17:03 GMT
x-cos-request-id: NTg3ZjJlMjVfNDYyMDRlXzM0YzRfMjc1

<CompleteMultipartUploadResult>
    <Location>examplebucket-1250000000.cos.city.yfm4.fsphere.cn/ObjectName</Location>
    <Bucket>examplebucket-1250000000</Bucket>
    <Key>examplebucket</Key>
    <ETag>"3a0f1fd698c235af9cf098cb74aa25bc"</ETag>
</CompleteMultipartUploadResult>