All Products
Search
Document Center

Object Storage Service:complete-multipart-upload

Last Updated:Apr 07, 2025

Completes the multipart upload task of an object.

Usage notes

  • When you run the complete-multipart-upload command, you must provide a complete list of all valid parts, including the part number and entity tag (ETag) of each part. The value of PartNumber ranges from 1 to 10,000. The part numbers listed in the request can be non-consecutive but must be sorted in ascending order. Object Storage Service (OSS) sequentially verifies the validity of each part and checks whether each part except the last part is larger than or equal to 100 KB in size. After all parts are verified, OSS combines these parts into a complete object.

  • A specific period of time is required for OSS to process a CompleteMultipartUpload request. If the client is disconnected from OSS during the specified period of time, OSS continues to process the request.

  • You can upload an object by running multiple upload tasks that have independent upload IDs. When one multiple upload task is complete, its upload ID becomes invalid but the upload IDs of other multiple upload tasks are not affected.

Permissions

By default, an Alibaba Cloud account has full permissions on resources in the account. In contrast, RAM users and RAM roles associated with an Alibaba Cloud account initially have no permissions. To manage resources by using a RAM user or role, you must grant the required permissions via RAM policies or Bucket policies.

API

Action

Description

CompleteMultipartUpload

oss:PutObject

Combines parts into an object.

oss:PutObjectTagging

Specifies the tags of the object by using the x-oss-tagging header when you combine parts into an object.

Syntax

ossutil api complete-multipart-upload --bucket value --key value --upload-id value --complete-multipart-upload value [flags]

Parameter

Type

Description

--bucket

string

The name of the bucket to which you want to upload the object.

--complete-all

string

Specifies whether to list all parts that are uploaded by using the current upload ID.

--complete-multipart-upload

string

The container that stores the content of the CompleteMultipartUpload request.

--encoding-type

string

The encoding type of the object name in the response.

--forbid-overwrite

string

Specifies whether the complete-multipart-upload command overwrites an existing object that has the same name as the object that you want to upload.

--key

string

The full path of the object.

--upload-id

string

The ID of the multipart upload task.

Note

The complete-multipart-upload command corresponds to the CompleteMultipartUpload operation. For more information about the parameters in the CompleteMultipartUploadoperation, see CompleteMultipartUpload.

--complete-multipart-upload

The --complete-multipart-upload option supports both the XML and JSON formats. If the value of the option contains the file:// prefix, the configurations are read from the configuration file.

  • XML format:

    <CompleteMultipartUpload>
      <Part>
        <PartNumber>integer</PartNumber>
        <ETag>string</ETag>
      </Part>
      ...
    </CompleteMultipartUpload>
  • JSON format:

    {
      "Part": [
        {
          "PartNumber": integer,
          "ETag": "string"
        },
        ...
      ]
    }
Note

For more information about supported global command-line options, see Global command-line options.

Examples

The following examples describe how to upload the exampleobject object to the examplebucket bucket by using multipart upload. The upload ID of the multipart upload task is 123.

  • Create an XML configuration file named complete-multipart-upload.xml and add the following code to the configuration file:

    <?xml version="1.0" encoding="UTF-8"?>
    <CompleteMultipartUpload>
      <Part>
        <PartNumber>1</PartNumber>
        <ETag>"C884BAB4F7A89D38A194568C7DE****"</ETag>
      </Part>
      <Part>
        <PartNumber>2</PartNumber>
        <ETag>"C884BAB4F7A89D38A194568C7DEA****"</ETag>
      </Part>
    </CompleteMultipartUpload>

Sample command:

ossutil api complete-multipart-upload --bucket examplebucket --key exampleobject --upload-id 123 --complete-multipart-upload file://complete-multipart-upload.xml
  • Create a JSON configuration file named complete-multipart-upload.json and add the following code to the configuration file:

    {
      "Part": [
        {
          "PartNumber": "1",
          "ETag": "\"C884BAB4F7A89D38A194568C7DE****\""
        },
        {
          "PartNumber": "2",
          "ETag": "\"C884BAB4F7A89D38A194568C7DEA****\""
        }
      ]
    }

    Sample command:

    ossutil api complete-multipart-upload --bucket examplebucket --key exampleobject --upload-id 123 --complete-multipart-upload file://complete-multipart-upload.json
  • Configure parameters in the following command in the JSON format:

    ossutil api complete-multipart-upload --bucket examplebucket --key exampleobject --upload-id 123 --complete-multipart-upload file://complete-multipart-upload.json

The following example describes how to list all uploaded parts whose upload ID is 123 in the examplebucket bucket:

ossutil api complete-multipart-upload --bucket examplebucket --key exampleobject --upload-id 123 --complete-all yes