Updated on 2026-05-26 GMT+08:00

Completing a Multipart Upload

Function

After all parts are uploaded, you can call this API to assemble specified parts into an object.

Before performing this operation, you cannot download the uploaded data. When merging parts, you need to copy the additional message header information recorded during the initialization of the multipart upload task to the object metadata. The processing process is the same as that of the common upload object with these message headers. In the case of merging parts concurrently, the Last Write Win policy must be followed but the time for initiating Last Write is specified as the time when a part multipart upload is initiated.

As long as the multipart upload is not aborted, all uploaded parts occupy the space. However, after you assembled the specified parts, the uploaded but not assembled parts will be deleted to free up space.

You can send a request for downloading all or some data of the generated multipart by specifying a range.

You can send a request for deleting all parts uploaded in a multipart upload. Deleted data cannot be restored.

The merged parts do not use the MD5 value of the entire object as the ETag. Their 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 Sample Request, there are three parts and each part has an MD5 value. The MD5 values of the three parts are recalculated to obtain a new MD5 value. Then -N is added to the right of the MD5 value to get the ETag of the combined parts. In this example, -N is -3.

If the response to an object assembling request timed out and error 500 or 503 was returned, you can first obtain the object metadata of the multipart upload task. Then, check whether the value of header x-obs-uploadId in the response is the same as the ID of the current multipart upload task. If they are, it means the object parts have been successfully assembled on the server and you do not need to try again. For details, see Consistency of Concurrent Operations.

Working with Other Functions

If a bucket has WORM enabled, the WORM protection will be automatically applied to the object generated after a multipart upload is complete. If you specify WORM headers and a retention expiration date when you initiate a multipart upload, the protection for the assembled object ends on the specified date. If you do not specify WORM headers during the initiation, but have configured the default bucket-level retention policy, this default policy is automatically applied and the protection starts when the multipart upload is complete. After a multipart upload is complete, you can still configure object-level WORM retention policies for the assembled object.

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-obs-version-id. If versioning is suspended for a bucket, the version ID of the object obtained from assembling the parts is null. For details about the versioning status of a bucket, see Configuring Versioning for a Bucket.

If 10 parts are uploaded but only nine parts are selected for merge, the parts that are not merged will be automatically deleted by the system. The parts that are not merged cannot be restored after being deleted. 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.

Authorization

To call this API, you must be the bucket owner or have the permission to complete a multipart upload. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

  • If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permissions:
    • If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you must have the obs:object:PutObject permission. For details, see Creating a Custom IAM Policy.
    • If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you must have the obs:object:putObject permission, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.

      Action

      Access Level

      Resource Type (*: Required)

      Condition Key

      Alias

      Dependencies

      obs:object:putObject

      Permission_management

      object *

      g:EnterpriseProjectId

      -

      • functiongraph:function:invokeAsync
      • functiongraph:workflow:invoke
      • smn:topic:publish

      -

      • obs:EpochTime
      • obs:SourceIp
      • obs:TlsVersion
      • obs:CustomDomain
      • obs:x-obs-acl
  • If you use bucket policies for authorization, you must have the obs:object:putObject permission. For details, see Creating a Custom Bucket Policy.

URI

POST /{object_key}

Calling Method

For details, see Calling APIs. Before calling this API, calculate the API signature and add it to the request.

You can debug this API in API Explorer.

Request Syntax

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
POST /ObjectName?uploadId=uploadID HTTP/1.1 
Host: bucketname.obs.region.myhuaweicloud.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>

URI Parameters

This request uses parameters to specify the ID of a multipart upload whose parts will be assembled. Table 1 describes the parameters.

Table 1 URI parameters

Parameter

Type

Mandatory

Description

uploadId

String

Yes

Definition

Multipart upload ID.

Range

The value must contain 32 characters.

Default Value

N/A

encoding-type

String

No

Definition

Encodes the Key in the response based on the specified type. If Key in the response contains control characters that are not supported by the XML 1.0 standard, you can specify this parameter to encode Key.

Constraints

N/A

Range

URL

Default Value

N/A. If you do not configure this parameter, encoding is not applied.

Request Headers

This request uses common headers. For details, see Table 3.

Request Body

This request uses elements to specify the list of parts to be assembled. Table 2 describes the elements.

Table 2 Request body parameters

Element

Type

Mandatory

Description

CompleteMultipartUpload

XML

Yes

Definition

List of parts to be assembled

Constraints

N/A

Range

N/A

Default Value

N/A

part

XML

Yes

Definition

Parent node of the part information, that is, the parent node of PartNumber and ETag. It indicates a part to be assembled.

Constraints

N/A

Range

N/A

Default Value

N/A

PartNumber

Integer

Yes

Definition

Part number

Constraints

N/A

Range

[1,10000]

Default Value

N/A

ETag

String

Yes

Definition

ETag value returned upon successful upload of a part. It is the unique identifier of the part content. This parameter is used to verify data consistency when parts are merged.

Constraints

N/A

Range

The value must contain 32 characters.

Default Value

N/A

Response Syntax

1
2
3
4
5
6
7
8
9
HTTP/1.1 status_code
Date: date
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> 
<CompleteMultipartUploadResult xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/">
    <Location>http://example-Bucket.obs.region.myhuaweicloud.com/example-Object</Location>
    <Bucket>bucketname</Bucket> 
    <Key>ObjectName</Key> 
    <ETag>ETag</ETag> 
</CompleteMultipartUploadResult>

Response Headers

This response uses common headers. For details, see Table 1.

In addition to the common response headers, the headers listed in Table 3 may be used.

Table 3 Response headers

Header

Type

Description

x-obs-version-id

String

Definition

Version of the object after parts are assembled.

Constraints

N/A

Range

The value must contain 32 characters.

Default Value

N/A

x-obs-server-side-encryption

String

Definition

The encryption method used by the server.

Example: x-obs-server-side-encryption:kms

Constraints

This header is included in a response if SSE-KMS is used.

Range

  • kms: SSE-KMS is used for encryption.
  • AES256: SSE-OBS and the AES256 algorithm are used.

Default Value

N/A

x-obs-server-side-encryption-kms-key-id

String

Definition

ID of a specified key used for SSE-KMS encryption. For details about how to obtain a key ID, see Viewing a Key.

Constraints

This header can only be used when you specify kms for the x-obs-server-side-encryption header.

Default Value

If you specify kms for encryption but do not specify a key ID, the default master key will be used. If there is no default master key, OBS will create one and use it.

x-obs-sse-kms-key-project-id

String

Definition

If SSE-KMS encryption is used with a custom master key, the ID of the project (not enterprise project) to which the custom master key belongs is returned.

Range

ID of the project (not enterprise project) to which the custom master key specified by x-obs-server-side-encryption-kms-key-id belongs

x-obs-server-side-encryption-customer-algorithm

String

Definition

The algorithm used for encryption.

Example: x-obs-server-side-encryption-customer-algorithm:AES256

Constraints

This header is included in a response if SSE-C is used for server-side encryption.

Range

AES256

Default Value

N/A

Response Body

This response uses elements to return the result of assembling parts. Table 4 describes the elements.

Table 4 Response body parameters

Element

Type

Description

Location

String

Definition

Path of the object after parts are assembled.

Constraints

Format: http://bucketName.obs.region.myhuaweicloud.com/objectName

Range

N/A

Default Value

N/A

Bucket

String

Definition

Bucket where parts are assembled

Constraints

  • A bucket name must be unique across all accounts and regions.
  • A bucket name:
    • Must be 3 to 63 characters long and start with a digit or letter. Lowercase letters, digits, hyphens (-), and periods (.) are allowed.
    • Cannot be formatted as an IP address.
    • Cannot start or end with a hyphen (-) or period (.).
    • Cannot contain two consecutive periods (..), for example, my..bucket.
    • Cannot contain a period (.) and a hyphen (-) adjacent to each other, for example, my-.bucket or my.-bucket.
  • If you repeatedly create buckets of the same name in the same region, no error will be reported and the bucket attributes comply with those set in the first creation request.

Range

N/A

Default Value

N/A

EncodingType

String

Definition

Encoding type of an object key. If Key in the response contains control characters that are not supported by the XML 1.0 standard, you can specify this parameter to encode Key.

Constraints

N/A

Range

URL

Default Value

N/A. If you do not configure this parameter, encoding is not applied.

Key

String

Definition

Object name obtained after part assembling.

An object is uniquely identified by an object name in a bucket. An object name is a complete path that does not contain the bucket name.

For example, if the access path is examplebucket.obs.ap-southeast-1.myhuaweicloud.com/folder/test.txt, the object name is folder/test.txt.

Constraints

See Object Overview.

Range

The value must contain 1 to 1,024 characters.

Default Value

N/A

ETag

String

Definition

The ETag that uniquely identifies the object after its parts were assembled, calculated based on the ETag of each part.

Constraints

If an object is encrypted using server-side encryption, the ETag is not the MD5 value of the object.

Range

The value must contain 32 characters.

Default Value

N/A

Error Responses

  1. If no message body exists, OBS returns 400 Bad Request.
  2. If the message body format is incorrect, OBS returns 400 Bad Request.
  3. If the part information in the message body is not sorted by part sequence number, OBS returns 400 Bad Request and the error code is InvalidPartOrder.
  4. If the AK or signature is invalid, OBS returns 403 Forbidden and the error code is AccessDenied.
  5. If the requested bucket is not found, OBS returns 404 Not Found and the error code is NoSuchBucket.
  6. If the requested multipart upload does not exist, OBS returns 404 Not Found and error code NoSuchUpload.
  7. If the user is not the initiator of the task, OBS returns 403 Forbidden and the error code is AccessDenied.
  8. If the request part list contains a part that does not exist, OBS returns 400 Bad Request and the error code is InvalidPart.
  9. If the part's ETag contained in the request list is incorrect, OBS returns 400 Bad Request with an error code of InvalidPart.
  10. If the size of a part other than the last part is smaller than 100 KB, OBS returns 400 Bad Request.
  11. If the size of the object is greater than 48.8 TB after parts being merged, OBS returns status code 400 Bad Request.

Other errors are included in Table 2.

Sample Request

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
POST /object02?uploadId=00000163D46218698DF407362295674C HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Accept: */*
Date: WED, 01 Jul 2015 05:23:46 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:dOfK9iILcKxo58tRp3fWeDoYzKA=
Content-Length: 422

<?xml version="1.0" encoding="utf-8"?>
<CompleteMultipartUpload> 
  <Part> 
    <PartNumber>1</PartNumber>  
    <ETag>a54357aff0632cce46d942af68356b38</ETag> 
  </Part>  
  <Part> 
    <PartNumber>2</PartNumber>  
    <ETag>0c78aef83f66abc1fa1e8477f296d394</ETag> 
  </Part>  
  <Part> 
    <PartNumber>3</PartNumber>  
    <ETag>acbd18db4cc2f85cedef654fccc4a4d8</ETag> 
  </Part>
</CompleteMultipartUpload>

Sample Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
HTTP/1.1 200 OK
Server: OBS
x-obs-request-id: 8DF400000163D4625BE3075019BD02B8
x-obs-id-2: 32AAAQAAEAABAAAQAAEAABAAAQAAEAABCSN8D1AfQcIvyGBZ9+Ee+jU6zv1iYdO4
Content-Type: application/xml
Date: WED, 01 Jul 2015 05:23:46 GMT
Content-Length: 326

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CompleteMultipartUploadResult xmlns="http://obs.region.myhuaweicloud.com/doc/2015-06-30/">
    <Location>http://examplebucket.obs.region.myhuaweicloud.com/object02</Location>
    <Bucket>examplebucket</Bucket>
    <Key>object02</Key>
    <ETag>"03f814825e5a691489b947a2e120b2d3-3"</ETag>
</CompleteMultipartUploadResult>