complete_multipart_upload
async
¶
complete_multipart_upload(
bucket: BucketName,
key: ObjectKey,
upload_id: MultipartUploadId,
*,
config_overrides: Optional[AsyncS3ClientConfig] = None,
multipart_upload: Optional[CompletedMultipartUpload] = None,
checksum_crc32: Optional[ChecksumCRC32] = None,
checksum_crc32_c: Optional[ChecksumCRC32C] = None,
checksum_crc64_nvme: Optional[ChecksumCRC64NVME] = None,
checksum_sha1: Optional[ChecksumSHA1] = None,
checksum_sha256: Optional[ChecksumSHA256] = None,
checksum_sha512: Optional[ChecksumSHA512] = None,
checksum_md5: Optional[ChecksumMD5] = None,
checksum_xxhash64: Optional[ChecksumXXHASH64] = None,
checksum_xxhash3: Optional[ChecksumXXHASH3] = None,
checksum_xxhash128: Optional[ChecksumXXHASH128] = None,
checksum_type: Optional[ChecksumType] = None,
mpu_object_size: Optional[MpuObjectSize] = None,
request_payer: Optional[RequestPayer] = None,
expected_bucket_owner: Optional[AccountId] = None,
if_match: Optional[IfMatch] = None,
if_none_match: Optional[IfNoneMatch] = None,
sse_customer_algorithm: Optional[SSECustomerAlgorithm] = None,
sse_customer_key: Optional[SSECustomerKey] = None,
sse_customer_key_md5: Optional[SSECustomerKeyMD5] = None,
) -> CompleteMultipartUploadOutput
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.
- Permissions
-
-
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
MultipartUploadrequests and the object is encrypted with Key Management Service, you must have permission to use thekms:Decryptaction for theCompleteMultipartUploadrequest to succeed. -
Directory bucket permissions - To grant access to this API operation on a directory bucket, we recommend that you use the
CreateSessionAPI operation for session-based authorization. Specifically, you grant thes3express:CreateSessionpermission to the directory bucket in a bucket policy or an IAM identity-based policy. Then, you make theCreateSessionAPI 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 anotherCreateSessionAPI 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, seeCreateSession.If the object is encrypted with SSE-KMS, you must also have the
kms:GenerateDataKeyandkms:Decryptpermissions in IAM identity-based policies and KMS key policies for the KMS key.
-
- Special errors
-
-
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
-
-
- HTTP Host header syntax
-
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.
Parameters:
-
bucket(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
Bucket-name.s3express-zone-id.region-code.amazonaws.com. Path-style requests are not supported. Directory bucket names must be unique in the chosen Zone (Availability Zone or Local Zone). Bucket names must follow the formatbucket-base-name--zone-id--x-s3(for example,amzn-s3-demo-bucket--usw2-az1--x-s3). For information about bucket naming restrictions, see Directory bucket naming rules in the Amazon S3 User Guide.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
AccessPointName-AccountId.outpostID.s3-outposts.Region.amazonaws.com. When you use this action with S3 on Outposts, the destination bucket must be the Outposts access point ARN or the access point alias. For more information about S3 on Outposts, see What is S3 on Outposts? in the Amazon S3 User Guide. -
key(ObjectKey) –Object key for which the multipart upload was initiated.
-
multipart_upload(Optional[CompletedMultipartUpload], default:None) –The container for the multipart upload request information.
-
upload_id(MultipartUploadId) –ID for the initiated multipart upload.
-
checksum_crc32(Optional[ChecksumCRC32], default:None) –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
CRC32checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_crc32_c(Optional[ChecksumCRC32C], default:None) –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
CRC32Cchecksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_crc64_nvme(Optional[ChecksumCRC64NVME], default:None) –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
CRC64NVMEchecksum of the object. TheCRC64NVMEchecksum is always a full object checksum. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_sha1(Optional[ChecksumSHA1], default:None) –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
SHA1digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_sha256(Optional[ChecksumSHA256], default:None) –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
SHA256digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_sha512(Optional[ChecksumSHA512], default:None) –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, 512-bit
SHA512digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_md5(Optional[ChecksumMD5], default:None) –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, 128-bit
MD5digest of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_xxhash64(Optional[ChecksumXXHASH64], default:None) –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
XXHASH64checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_xxhash3(Optional[ChecksumXXHASH3], default:None) –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
XXHASH3checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_xxhash128(Optional[ChecksumXXHASH128], default:None) –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, 128-bit
XXHASH128checksum of the object. For more information, see Checking object integrity in the Amazon S3 User Guide. -
checksum_type(Optional[ChecksumType], default:None) –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
CreateMultipartUploadrequest, it’ll result in aBadDigesterror. For more information, see Checking object integrity in the Amazon S3 User Guide. -
mpu_object_size(Optional[MpuObjectSize], default:None) –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
HTTP 400 InvalidRequesterror. -
expected_bucket_owner(Optional[AccountId], default:None) –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
403 Forbidden(access denied). -
if_match(Optional[IfMatch], default:None) –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
412 Precondition Failederror.If a conflicting operation occurs during the upload S3 returns a
409 ConditionalRequestConflictresponse. On a 409 failure you should fetch the object's ETag, re-initiate the multipart upload withCreateMultipartUpload, and re-upload each part.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.
-
if_none_match(Optional[IfNoneMatch], default:None) –Uploads the object only if the object key name does not already exist in the bucket specified. Otherwise, Amazon S3 returns a
412 Precondition Failederror.If a conflicting operation occurs during the upload S3 returns a
409 ConditionalRequestConflictresponse. On a 409 failure you should re-initiate the multipart upload withCreateMultipartUploadand re-upload each part.Expects the '*' (asterisk) character.
For more information about conditional requests, see RFC 7232, or Conditional requests in the Amazon S3 User Guide.
-
sse_customer_algorithm(Optional[SSECustomerAlgorithm], default:None) –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.
-
sse_customer_key(Optional[SSECustomerKey], default:None) –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.
-
sse_customer_key_md5(Optional[SSECustomerKeyMD5], default:None) –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.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To complete multipart upload The following example completes a multipart upload.
>>> await client.complete_multipart_upload(bucket='examplebucket', key='bigobject', multipart_upload={'Parts': [{'PartNumber': 1, 'ETag': '"d8c2eafd90c266e19ab9dcacc479f8af"'}, {'PartNumber': 2, 'ETag': '"d8c2eafd90c266e19ab9dcacc479f8af"'}]}, upload_id='7YPBOJuoFiQ9cz4P3Pe6FIZwO4f7wN93uHsNBEw97pl5eNwzExg0LAT2dUN91cOmrEQHDsP3WA60CEg--')
Source code in docs_src/capo_s3/_services/async_s3.py
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | |