complete-multipart-upload

Updated at:

The complete-multipart-upload command is used to complete a multipart upload for an entire file.

Usage notes

  • When you call the complete-multipart-upload operation, you must provide a list of all valid parts, including PartNumber and ETag. PartNumber values range from 1 to 10000 and must be in ascending order, but do not need to be consecutive. OSS verifies the validity of each part and ensures that every part except the last one is no smaller than 100 KB. After verification, these parts are combined into a complete object.

  • OSS takes a certain amount of time to process a CompleteMultipartUpload request. If the connection between the client and OSS is interrupted during this period, OSS continues to process the request.

  • The same object can have multiple UploadIds at the same time. After an UploadId is completed, this UploadId becomes invalid, but other UploadIds of the object are not affected.

Permissions

By default, an Alibaba Cloud account has full permissions. RAM users or RAM roles under an Alibaba Cloud account do not have any permissions by default. The Alibaba Cloud account or account administrator must grant operation permissions through RAM policies or Bucket Policy.

API

Action

Description

CompleteMultipartUpload

oss:PutObject

Merges parts into an object.

oss:PutObjectTagging

When merging parts into an object, if you specify object tags through x-oss-tagging, this permission is required.

Command 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 destination bucket.

--complete-all

string

Specifies whether to list all parts that have been uploaded for the current UploadId.

--complete-multipart-upload

string

The container that stores the content of the CompleteMultipartUpload request.

--encoding-type

string

The encoding type for the returned content.

--forbid-overwrite

string

Specifies whether to overwrite an existing object with the same name during the CompleteMultipartUpload operation.

--key

string

The full path of the object.

--upload-id

string

The ID of the multipart upload event.

Note

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

--complete-multipart-upload

The --complete-multipart-upload option supports both XML and JSON syntax. When the option value contains the file:// prefix, the configuration is read from a file.

  • XML syntax:

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

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

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

Examples

The following examples show how to complete a multipart upload for the object exampleobject with the upload ID 123 in the bucket examplebucket.

  • Use an XML configuration file. The content of complete-multipart-upload.xml is as follows:

    <?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
  • Use a JSON configuration file. The content of complete-multipart-upload.json is as follows:

    {
      "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
  • Use JSON configuration parameters. Sample command:

    ossutil api complete-multipart-upload --bucket examplebucket --key exampleobject --upload-id 123 --complete-multipart-upload file://complete-multipart-upload.json=》ossutil api complete-multipart-upload --bucket examplebucket --key exampleobject --upload-id 123 --complete-multipart-upload "{\"Part\":[{\"PartNumber\":\"1\",\"ETag\":\"\\\"C884BAB4F7A89D38A194568C7DE****\\\"\"},{\"PartNumber\":\"2\",\"ETag\":\"\\\"C884BAB4F7A89D38A194568C7DEA****\\\"\"}]}"

The following example shows how to list all parts that have been uploaded for the upload ID 123 in the bucket examplebucket.

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