You can call this operation to complete multipart upload of an object.

When you perform this operation, you must provide a complete list of parts. Information of each part must contain a part number and entity tag (ETag). After OSS receives the list of parts, OSS verifies the validity of each part one by one. After all these parts have been verified, OSS combines these parts into a complete object.

Note
  • When you perform this operation, OSS checks whether the size of each part except the last part is larger than 100 KB and whether the part number and ETag are provided for each part in the list. When each part is uploaded, the client must record the part number and the ETag value returned from the server after each part is uploaded.
  • It may take a while for OSS to process the CompleteMultipartUpload request. If the client is disconnected from OSS during this period, OSS continues to process the request.
  • The part numbers listed in the request do not have to be consecutive. For example, the first part number can be 1 and the second part number can be 5.
  • After OSS processes the CompleteMultipartUpload request, the upload ID of this task is no longer valid.
  • An object may have different upload IDs that are independent of each other. When one upload task is completed, the corresponding upload ID becomes invalid and other upload IDs are not affected.
  • If InitiateMultipartUpload is called and the x-oss-server-side-encryption request header is specified, the x-oss-server-side-encryption response header is returned in response to the CompleteMultipartUpload request. The x-oss-server-side-encryption response header indicates the sever-side encryption method for the object.

Request syntax

POST /ObjectName?uploadId=UploadId HTTP/1.1
Host: BucketName.oss-cn-hangzhou.aliyuncs.com
Date: GMT Date
Content-Length: Size
Authorization: Signature
<CompleteMultipartUpload>
<Part>
<PartNumber>PartNumber</PartNumber>
<ETag>ETag</ETag>
</Part>
...
</CompleteMultipartUpload>

Request parameters

The Encoding-type parameter can be specified in the CompleteMultipartUpload request. OSS uses the specified encoding type to encode the object name in the response.
Parameter Type Description
Encoding-type String The encoding type of the object name in the response. The object name can contain any characters encoded in UTF-8. However, the XML 1.0 standard cannot be used to parse certain control characters, such as characters with an ASCII value from 0 to 10. You can set the Encoding-type parameter to encode the returned object name. Set the value to url.

Default value: null

Valid value: url

Request elements

Element Type Description
CompleteMultipartUpload Container The container that stores the content of the CompleteMultipartUpload request.

Child node: one or more Part elements

Parent node: none

ETag String The ETag value returned by OSS after the part is uploaded.

Parent node: Part

Part Container The container that stores information about the uploaded part.

Child node: ETag and PartNumber

Parent node: InitiateMultipartUploadResult

PartNumber Integer The number of the part.

Parent node: Part

Response elements

Element Type Description
Bucket String The name of the bucket.

Parent node: CompleteMultipartUploadResult

CompleteMultipartUploadResult Container The container that stores the response to the CompleteMultipartUpload request.

Child node: Bucket, Key, ETag, and Location

Parent node: none

ETag String The ETag created to identify the content of the object when the object is created through the CompleteMultipartUpload request. The ETag value is the UUID of the object content. The ETag value of the object can be used to check whether the object content is modified.

Parent node: CompleteMultipartUploadResult

Location String The URL used to access the object.

Parent node: CompleteMultipartUploadResult

Key String The name of the object.

Parent node: CompleteMultipartUploadResult

EncodingType String The encoding type of the object name in the response. If the encoding-type parameter is specified in the request, the object name in the response is encoded.

Parent node: CompleteMultipartUploadResult

Examples

  • Sample requests
    POST /multipart.data? uploadId=0004B9B2D2F7815C432C9057C03134D4  HTTP/1.1
    Host: oss-example.oss-cn-hangzhou.aliyuncs.com
    Content-Length: 1056
    Date: Fri, 24 Feb 2012 10:19:18 GMT
    Authorization: OSS qn6qrrqxo2oawuk53otfjbyc:8VwFhFUWmVecK6jQlHlXMK/z****
    <CompleteMultipartUpload> 
        <Part> 
            <PartNumber>1</PartNumber>  
            <ETag>"3349DC700140D7F86A0784842780****"</ETag> 
        </Part>  
        <Part> 
            <PartNumber>5</PartNumber>  
            <ETag>"8EFDA8BE206636A695359836FE0A****"</ETag> 
        </Part>  
        <Part> 
            <PartNumber>8</PartNumber>  
            <ETag>"8C315065167132444177411FDA14****"</ETag> 
        </Part> 
    </CompleteMultipartUpload>
    Sample responses
    HTTP/1.1 200 OK
    Server: AliyunOSS
    Content-Length: 329
    Content-Type: Application/xml
    Connection: keep-alive
    x-oss-request-id: 594f0751-3b1e-168f-4501-4ac71d21****
    Date: Fri, 24 Feb 2012 10:19:18 GMT
    <?xml version="1.0" encoding="UTF-8"?>
    <CompleteMultipartUploadResult xmlns=”http://doc.oss-cn-hangzhou.aliyuncs.com”>
        <Location>http://oss-example.oss-cn-hangzhou.aliyuncs.com /multipart.data</Location>
        <Bucket>oss-example</Bucket>
        <Key>multipart.data</Key>
        <ETag>B864DB6A936D376F9F8D3ED3BBE540****</ETag>
    </CompleteMultipartUploadResult>

SDKs

You can call this operation when you use SDK demos in any of the following languages:

Error codes

Error code HTTP status code Description
InvalidDigest 400 The error message returned because Content-MD5 value in the request and the MD5 value calculated by OSS are inconsistent. To make sure that no errors occur during data transmission over the network, you can include the Content-MD5 value in the request. OSS calculates the MD5 value of the uploaded data and compares it with the Content-MD5 value.