AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.
Container for the parameters to the CompleteMultipartUpload operation. Completes a multipart upload by assembling previously uploaded parts.
You first initiate the multipart upload and then upload all parts using the UploadPart
operation or the UploadPartCopy
operation. After successfully uploading all relevant parts of an upload, you call
this CompleteMultipartUpload 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 CompleteMultipartUpload request, you must provide the
parts list and ensure that the parts list is complete. The CompleteMultipartUpload
API operation concatenates the parts that you provide in the list. For each part in
the list, you must provide the PartNumber value and the ETag value that
are returned after that part was uploaded.
The processing of a CompleteMultipartUpload request could take several minutes to
finalize. 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 white space characters to keep the connection from timing out.
A request could fail after the initial 200 OK response has been sent. This
means that a 200 OK response can contain either a success or an error. The
error response might be embedded in the 200 OK response. If you call this API
operation directly, make sure to design your application to parse the contents of
the response and handle it appropriately. If you use Amazon Web Services SDKs, SDKs
handle this condition. The SDKs detect the embedded error and apply error handling
per your configuration settings (including automatically retrying the request as appropriate).
If the condition persists, the SDKs throw an exception (or, for the SDKs that don't
use exceptions, they return an error).
Note that if CompleteMultipartUpload fails, applications should be prepared
to retry any failed requests (including 500 error responses). For more information,
see Amazon
S3 Error Best Practices.
You can't use Content-Type: application/x-www-form-urlencoded for the CompleteMultipartUpload
requests. Also, if you don't provide a Content-Type header, CompleteMultipartUpload
can still return a 200 OK response.
For more information about multipart uploads, see Uploading Objects Using Multipart Upload in the Amazon S3 User Guide.
Directory buckets - For directory buckets, you must make requests for this
API operation to the Zonal endpoint. These endpoints support virtual-hosted-style
requests in the format https://amzn-s3-demo-bucket.s3express-zone-id.region-code.amazonaws.com/key-name. Path-style requests are not supported. For more information about endpoints
in Availability Zones, see Regional
and Zonal endpoints for directory buckets in Availability Zones in the Amazon
S3 User Guide. For more information about endpoints in Local Zones, see Concepts
for directory buckets in Local Zones in the Amazon S3 User Guide.
General purpose bucket permissions - For information about permissions required to use the multipart upload API, see Multipart Upload and Permissions in the Amazon S3 User Guide.
If you provide an additional
checksum value in your MultipartUpload requests and the object is encrypted
with Key Management Service, you must have permission to use the kms:Decrypt
action for the CompleteMultipartUpload request to succeed.
Directory bucket permissions - To grant access to this API operation on a
directory bucket, we recommend that you use the CreateSession API operation for session-based authorization. Specifically,
you grant the s3express:CreateSession permission to the directory bucket in
a bucket policy or an IAM identity-based policy. Then, you make the CreateSession
API call on the bucket to obtain a session token. With the session token in your request
header, you can make API requests to this operation. After the session token expires,
you make another CreateSession API call to generate a new session token for
use. Amazon Web Services CLI or SDKs create session and refresh the session token
automatically to avoid service interruptions when a session expires. For more information
about authorization, see CreateSession.
If the object is encrypted with SSE-KMS, you must also have the kms:GenerateDataKey
and kms:Decrypt permissions in IAM identity-based policies and KMS key policies
for the KMS key.
Error Code: EntityTooSmall
Description: 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.
HTTP Status Code: 400 Bad Request
Error Code: InvalidPart
Description: One or more of the specified parts could not be found. The part might not have been uploaded, or the specified ETag might not have matched the uploaded part's ETag.
HTTP Status Code: 400 Bad Request
Error Code: InvalidPartOrder
Description: The list of parts was not in ascending order. The parts list must be specified in order by part number.
HTTP Status Code: 400 Bad Request
Error Code: NoSuchUpload
Description: The specified multipart upload does not exist. The upload ID might be invalid, or the multipart upload might have been aborted or completed.
HTTP Status Code: 404 Not Found
Directory buckets - The HTTP Host header syntax is Bucket-name.s3express-zone-id.region-code.amazonaws.com.
The following operations are related to CompleteMultipartUpload:
You must URL encode any signed header values that contain spaces. For example, if
your header value is my file.txt, containing two spaces after my, you
must URL encode this value to my%20%20file.txt.
Namespace: Amazon.S3.Model
Assembly: AWSSDK.S3.dll
Version: 3.x.y.z
public class CompleteMultipartUploadRequest : AmazonWebServiceRequest IAmazonWebServiceRequest
The CompleteMultipartUploadRequest type exposes the following members
| Name | Description | |
|---|---|---|
|
CompleteMultipartUploadRequest() |
| Name | Type | Description | |
|---|---|---|---|
|
BucketName | System.String |
Gets and sets the property BucketName. Name of the bucket to which the multipart upload was initiated. Directory buckets - When you use this operation with a directory bucket, you
must use virtual-hosted-style requests in the format Access points - When you use this action with an access point for general purpose buckets, you must provide the alias of the access point in place of the bucket name or specify the access point ARN. When you use this action with an access point for directory buckets, you must provide the access point name in place of the bucket name. When using the access point ARN, you must direct requests to the access point hostname. The access point hostname takes the form AccessPointName-AccountId.s3-accesspoint.Region.amazonaws.com. When using this action with an access point through the Amazon Web Services SDKs, you provide the access point ARN in place of the bucket name. For more information about access point ARNs, see Using access points in the Amazon S3 User Guide. Object Lambda access points are not supported by directory buckets. S3 on Outposts - When you use this action with S3 on Outposts, you must direct
requests to the S3 on Outposts hostname. The S3 on Outposts hostname takes the form
|
|
ChecksumCRC32 | System.String |
Gets and sets the property ChecksumCRC32.
This header can be used as a data integrity check to verify that the data received
is the same data that was originally sent. This header specifies the Base64 encoded,
32-bit |
|
ChecksumCRC32C | System.String |
Gets and sets the property ChecksumCRC32C.
This header can be used as a data integrity check to verify that the data received
is the same data that was originally sent. This header specifies the Base64 encoded,
32-bit |
|
ChecksumCRC64NVME | System.String |
Gets and sets the property ChecksumCRC64NVME.
This header can be used as a data integrity check to verify that the data received
is the same data that was originally sent. This header specifies the Base64 encoded,
64-bit |
|
ChecksumSHA1 | System.String |
Gets and sets the property ChecksumSHA1.
This header can be used as a data integrity check to verify that the data received
is the same data that was originally sent. This header specifies the Base64 encoded,
160-bit |
|
ChecksumSHA256 | System.String |
Gets and sets the property ChecksumSHA256.
This header can be used as a data integrity check to verify that the data received
is the same data that was originally sent. This header specifies the Base64 encoded,
256-bit |
|
ChecksumType | Amazon.S3.ChecksumType |
Gets and sets the property ChecksumType.
This header specifies the checksum type of the object, which determines how part-level
checksums are combined to create an object-level checksum for multipart objects. You
can use this header as a data integrity check to verify that the checksum type that
is received is the same checksum that was specified. If the checksum type doesn’t
match the checksum type that was specified for the object during the |
|
ExpectedBucketOwner | System.String |
Gets and sets the property ExpectedBucketOwner.
The account ID of the expected bucket owner. If the account ID that you provide does
not match the actual owner of the bucket, the request fails with the HTTP status code
|
|
IfMatch | System.String |
Gets and sets the property IfMatch.
Uploads the object only if the ETag (entity tag) value provided during the WRITE operation
matches the ETag of the object in S3. If the ETag values do not match, the operation
returns a
If a conflicting operation occurs during the upload S3 returns a Expects the ETag value as a string. For more information about conditional requests, see RFC 7232, or Conditional requests in the Amazon S3 User Guide. |
|
IfNoneMatch | System.String |
Gets and sets the property IfNoneMatch.
Uploads the object only if the object key name does not already exist in the bucket
specified. Otherwise, Amazon S3 returns a
If a conflicting operation occurs during the upload S3 returns a Expects the '*' (asterisk) character. For more information about conditional requests, see RFC 7232, or Conditional requests in the Amazon S3 User Guide. |
|
Key | System.String |
Gets and sets the property Key. Object key for which the multipart upload was initiated. |
|
MpuObjectSize | System.Nullable<System.Int64> |
Gets and sets the property MpuObjectSize.
The expected total object size of the multipart upload request. If there’s a mismatch
between the specified object size value and the actual object size value, it results
in an |
|
PartETags | System.Collections.Generic.List<Amazon.S3.Model.PartETag> |
Gets and sets the property PartETags. Array of CompletedPart data types.
If you do not supply a valid |
|
RequestPayer | Amazon.S3.RequestPayer |
Gets and sets the property RequestPayer. |
|
SSECustomerAlgorithm | System.String |
Gets and sets the property SSECustomerAlgorithm. The server-side encryption (SSE) algorithm used to encrypt the object. This parameter is required only when the object was created using a checksum algorithm or if your bucket policy requires the use of SSE-C. For more information, see Protecting data using SSE-C keys in the Amazon S3 User Guide. This functionality is not supported for directory buckets. |
|
SSECustomerKey | System.String |
Gets and sets the property SSECustomerKey. The server-side encryption (SSE) customer managed key. This parameter is needed only when the object was created using a checksum algorithm. For more information, see Protecting data using SSE-C keys in the Amazon S3 User Guide. This functionality is not supported for directory buckets. |
|
SSECustomerKeyMD5 | System.String |
Gets and sets the property SSECustomerKeyMD5. The MD5 server-side encryption (SSE) customer managed key. This parameter is needed only when the object was created using a checksum algorithm. For more information, see Protecting data using SSE-C keys in the Amazon S3 User Guide. This functionality is not supported for directory buckets. |
|
UploadId | System.String |
Gets and sets the property UploadId. ID for the initiated multipart upload. |
| Name | Description | |
|---|---|---|
|
AddPartETags(PartETag[]) |
Adds a collection of parts (including ETags and checksums) to this request. |
|
AddPartETags(IEnumerable<PartETag>) |
Adds a collection of parts (including ETags and checksums) to this request. |
|
AddPartETags(UploadPartResponse[]) |
Adds a collection of part numbers and corresponding etags by transforming the UploadPartResponses into PartETags. |
|
AddPartETags(IEnumerable<UploadPartResponse>) |
Adds a collection of part numbers and corresponding etags by transforming the UploadPartResponses into PartETags. |
|
AddPartETags(CopyPartResponse[]) |
Adds a collection of part numbers and corresponding etags by transforming the CopyPartResponse into PartETags. |
|
AddPartETags(IEnumerable<CopyPartResponse>) |
Adds a collection of part numbers and corresponding etags by transforming the CopyPartResponse into PartETags. |
|
AddPartETagsAndChecksums(UploadPartResponse[]) |
Adds a collection of part numbers, ETags and checksums by transforming the UploadPartResponses into PartETags. |
|
AddPartETagsAndChecksums(IEnumerable<UploadPartResponse>) |
Adds a collection of part numbers, ETags and checksums by transforming the UploadPartResponses into PartETags. |
|
AddPartETagsAndChecksums(CopyPartResponse[]) |
Adds a collection of part numbers, ETags and checksums by transforming the UploadPartResponses into PartETags. |
|
AddPartETagsAndChecksums(IEnumerable<CopyPartResponse>) |
Adds a collection of part numbers, ETags and checksums by transforming the UploadPartResponses into PartETags. |
This example shows how to upload 13MB of data using mutlipart upload.
The data is contained in a stream and the upload is done in 3 parts:
5MB, 5MB, then the remainder.
int MB = (int)Math.Pow(2, 20);
// Create a client
AmazonS3Client client = new AmazonS3Client();
// Define input stream
Stream inputStream = Create13MBDataStream();
// Initiate multipart upload
InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest
{
BucketName = "amzn-s3-demo-bucket",
Key = "Item1"
};
InitiateMultipartUploadResponse initResponse = await client.InitiateMultipartUploadAsync(initRequest);
// Upload part 1
UploadPartRequest uploadRequest = new UploadPartRequest
{
BucketName = "amzn-s3-demo-bucket",
Key = "Item1",
UploadId = initResponse.UploadId,
PartNumber = 1,
PartSize = 5 * MB,
InputStream = inputStream
};
UploadPartResponse up1Response = await client.UploadPartAsync(uploadRequest);
// Upload part 2
uploadRequest = new UploadPartRequest
{
BucketName = "amzn-s3-demo-bucket",
Key = "Item1",
UploadId = initResponse.UploadId,
PartNumber = 2,
PartSize = 5 * MB,
InputStream = inputStream
};
UploadPartResponse up2Response = await client.UploadPartAsync(uploadRequest);
// Upload part 3
uploadRequest = new UploadPartRequest
{
BucketName = "amzn-s3-demo-bucket",
Key = "Item1",
UploadId = initResponse.UploadId,
PartNumber = 3,
InputStream = inputStream
};
UploadPartResponse up3Response = await client.UploadPartAsync(uploadRequest);
// List parts for current upload
ListPartsRequest listPartRequest = new ListPartsRequest
{
BucketName = "amzn-s3-demo-bucket",
Key = "Item1",
UploadId = initResponse.UploadId
};
ListPartsResponse listPartResponse = await client.ListPartsAsync(listPartRequest);
Debug.Assert(listPartResponse.Parts.Count == 3);
// Complete the multipart upload
CompleteMultipartUploadRequest compRequest = new CompleteMultipartUploadRequest
{
BucketName = "amzn-s3-demo-bucket",
Key = "Item1",
UploadId = initResponse.UploadId,
PartETags = new List<PartETag>
{
new PartETag { ETag = up1Response.ETag, PartNumber = 1 },
new PartETag { ETag = up2Response.ETag, PartNumber = 2 },
new PartETag { ETag = up3Response.ETag, PartNumber = 3 }
}
};
CompleteMultipartUploadResponse compResponse = await client.CompleteMultipartUploadAsync(compRequest);
.NET:
Supported in: 8.0 and newer, Core 3.1
.NET Standard:
Supported in: 2.0
.NET Framework:
Supported in: 4.7.2 and newer