Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use UploadPart
with an Amazon SDK or CLI
The following code examples show how to use UploadPart
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code examples:
- CLI
-
- Amazon CLI
-
The following command uploads the first part in a multipart upload initiated with the create-multipart-upload
command:
aws s3api upload-part --bucket my-bucket --key 'multipart/01' --part-number 1 --body part01 --upload-id "dfRtDYU0WWCCcH43C3WFbkRONycyCpTJJvxu2i5GYkZljF.Yxwh6XG7WfS2vC4to6HiV6Yjlx.cph0gtNBtJ8P3URCSbB7rjxI5iEwVDmgaXZOGgkk5nVTW16HOQ5l0R"
The body
option takes the name or path of a local file for upload (do not use the file:// prefix). The minimum part size is 5 MB. Upload ID is returned by create-multipart-upload
and can also be retrieved with list-multipart-uploads
. Bucket and key are specified when you create the multipart upload.
Output:
{
"ETag": "\"e868e0f4719e394144ef36531ee6824c\""
}
Save the ETag value of each part for later. They are required to complete the multipart upload.
- Rust
-
- SDK for Rust
-
let upload_part_res = client
.upload_part()
.key(&key)
.bucket(&bucket_name)
.upload_id(upload_id)
.body(stream)
.part_number(part_number)
.send()
.await?;
upload_parts.push(
CompletedPart::builder()
.e_tag(upload_part_res.e_tag.unwrap_or_default())
.part_number(part_number)
.build(),
);
let completed_multipart_upload: CompletedMultipartUpload = CompletedMultipartUpload::builder()
.set_parts(Some(upload_parts))
.build();
For a complete list of Amazon SDK developer guides and code examples, see
Using this service with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.