Menu
Amazon Simple Storage Service
API Reference (API Version 2006-03-01)

Complete Multipart Upload

Description

This operation completes a multipart upload by assembling previously uploaded parts.

You first initiate the multipart upload and then upload all parts using the Upload Parts operation (see Upload Part). After successfully uploading all relevant parts of an upload, you call this operation to complete the upload. Upon receiving this request, Amazon S3 concatenates all the parts in ascending order by part number to create a new object. In the Complete Multipart Upload request, you must provide the parts list. You must ensure the parts list is complete, this operation concatenates the parts you provide in the list. For each part in the list, you must provide the part number and the ETag header value, returned after that part was uploaded.

Processing of a Complete Multipart Upload request could take several minutes to complete. After Amazon S3 begins processing the request, it sends an HTTP response header that specifies a 200 OK response. While processing is in progress, Amazon S3 periodically sends whitespace characters to keep the connection from timing out. Because a request could fail after the initial 200 OK response has been sent, it is important that you check the response body to determine whether the request succeeded.

Note that if Complete Multipart Upload fails, applications should be prepared to retry the failed requests. For more information, go to Amazon S3 Error Best Practices section of the Amazon Simple Storage Service Developer Guide.

For more information on multipart uploads, go to Uploading Objects Using Multipart Upload in the Amazon Simple Storage Service Developer Guide.

For information on permissions required to use the multipart upload API, go to Multipart Upload API and Permissions in the Amazon Simple Storage Service Developer Guide.

Requests

Syntax

POST /ObjectName?uploadId=UploadId HTTP/1.1 Host: BucketName.s3.amazonaws.com Date: Date Content-Length: Size Authorization: authorization string <CompleteMultipartUpload> <Part> <PartNumber>PartNumber</PartNumber> <ETag>ETag</ETag> </Part> ... </CompleteMultipartUpload>

Request Parameters

This operation does not use request parameters.

Request Headers

This operation uses only Request Headers common to most requests. For more information, see Common Request Headers

Request Elements

Name Description Required
CompleteMultipartUpload

Container for the request.

Ancestor: None

Type: Container

Children: One or more Part elements

Yes
Part

Container for elements related to a particular previously uploaded part.

Ancestor: CompleteMultipartUpload

Type: Container

Children: PartNumber, ETag

Yes
PartNumber

Part number that identifies the part.

Ancestor: Part

Type: Integer

Yes
ETag

Entity tag returned when the part was uploaded.

Ancestor: Part

Type: String

Yes

Responses

Response Headers

The operation uses the following response header, in addition to the response headers common to most requests. For more information, see Common Response Headers.

Header Description
x-amz-expiration

Amazon S3 returns this header if an Expiration action is configured for the object as part of the bucket's lifecycle configuration.  The header value includes an "expiry-date" component and a URL-encoded "rule-id" component.  Note that for versioning-enabled buckets, this header applies only to current versions; Amazon S3 does not provide a header to infer when a noncurrent version will be eligible for permanent deletion. For more information, see PUT Bucket lifecycle.

Type: String

x-amz-server-side​-encryption

If you specified server-side encryption either with an AWS KMS or Amazon S3-managed encryption key in your initiate multipart upload request, the response includes this header. It confirms the encryption algorithm that Amazon S3 used to encrypt the object.

Type: String

x-amz-server-side-encryption-aws-kms-key-id

If the x-amz-server-side-encryption is present and has the value of aws:kms, this header specifies the ID of the AWS Key Management Service (KMS) master encryption key that was used for the object.

Type: String

x-amz-server-side​-encryption​-customer-algorithm

If encryption by using server-side encryption with customer-provided encryption keys was requested, the response will include this header confirming the encryption algorithm used.

Type: String

Valid Value: AES256

x-amz-version-id

Version ID of the newly created object, in case the bucket has versioning turned on.

Type: String

Response Elements

Name Description
CompleteMultipartUploadResult

Container for the response

Type: Container

Children: Location, Bucket, Key, ETag

Ancestors: None

Location

The URI that identifies the newly created object.

Type: URI

Ancestors: CompleteMultipartUploadResult

Bucket

The name of the bucket that contains the newly created object.

Type: String

Ancestors: CompleteMultipartUploadResult

Key

The object key of the newly created object.

Type: String

Ancestors: CompleteMultipartUploadResult

ETag

Entity tag that identifies the newly created object's data. Objects with different object data will have different entity tags. The entity tag is an opaque string. The entity tag may or may not be an MD5 digest of the object data. If the entity tag is not an MD5 digest of the object data, it will contain one or more nonhexadecimal characters and/or will consist of less than 32 or more than 32 hexadecimal digits.

Type: String

Ancestors: CompleteMultipartUploadResult

Special Errors

Error Code Description HTTP Status Code
EntityTooSmall Your proposed upload is smaller than the minimum allowed object size. Each part must be at least 5 MB in size, except the last part. 400 Bad Request
InvalidPart One or more of the specified parts could not be found. The part might not have been uploaded, or the specified entity tag might not have matched the part's entity tag. 400 Bad Request
InvalidPartOrder The list of parts was not in ascending order. The parts list must be specified in order by part number. 400 Bad Request
NoSuchUpload The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed. 404 Not Found

For general information about Amazon S3 errors and a list of error codes, see Error Responses.

Examples

Sample Request

The following Complete Multipart Upload request specifies three parts in the CompleteMultipartUpload element.

POST /example-object?uploadId=AAAsb2FkIElEIGZvciBlbHZpbmcncyWeeS1tb3ZpZS5tMnRzIRRwbG9hZA HTTP/1.1 Host: example-bucket.s3.amazonaws.com Date: Mon, 1 Nov 2010 20:34:56 GMT Content-Length: 391 Authorization: authorization string <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

The following response indicates that an object was successfully assembled.

HTTP/1.1 200 OK x-amz-id-2: Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg== x-amz-request-id: 656c76696e6727732072657175657374 Date: Mon, 1 Nov 2010 20:34:56 GMT Connection: close Server: AmazonS3 <?xml version="1.0" encoding="UTF-8"?> <CompleteMultipartUploadResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Location>http://Example-Bucket.s3.amazonaws.com/Example-Object</Location> <Bucket>Example-Bucket</Bucket> <Key>Example-Object</Key> <ETag>"3858f62230ac3c915f300c664312c11f-9"</ETag> </CompleteMultipartUploadResult>

Sample Response with Error Specified in Header

The following response indicates that an error occurred before the HTTP response header was sent.

HTTP/1.1 403 Forbidden x-amz-id-2: Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg== x-amz-request-id: 656c76696e6727732072657175657374 Date: Mon, 1 Nov 2010 20:34:56 GMT Content-Length: 237 Connection: keep-alive Server: AmazonS3 <?xml version="1.0" encoding="UTF-8"?> <Error> <Code>AccessDenied</Code> <Message>Access Denied</Message> <RequestId>656c76696e6727732072657175657374</RequestId> <HostId>Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==</HostId> </Error>

Sample Response with Error Specified in Body

The following response indicates that an error occurred after the HTTP response header was sent. Note that while the HTTP status code is 200 OK, the request actually failed as described in the Error element.

HTTP/1.1 200 OK x-amz-id-2: Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg== x-amz-request-id: 656c76696e6727732072657175657374 Date: Mon, 1 Nov 2010 20:34:56 GMT Connection: close Server: AmazonS3 <?xml version="1.0" encoding="UTF-8"?> <Error> <Code>InternalError</Code> <Message>We encountered an internal error. Please try again.</Message> <RequestId>656c76696e6727732072657175657374</RequestId> <HostId>Uuag1LuByRx9e6j5Onimru9pO4ZVKnJ2Qz7/C1NPcfTWAtRPfTaOFg==</HostId> </Error>