Upload one S3 multipart part
📑 On this page
Part 45 of AWS from Zero. This lesson keeps the scope to one S3 behavior you can verify from the terminal.
What we are learning
Each multipart part has a part number and an ETag. Except for the final part, S3 parts must meet the minimum part-size requirement.
Before you run it
BUCKET="replace-with-your-private-demo-bucket"
KEY="large-demo.bin"
UPLOAD_ID="replace-with-an-active-upload-id"
dd if=/dev/zero of=part-1.bin bs=1M count=6Use the upload ID returned by create-multipart-upload. The demo creates a 6 MiB part.
The command
ETAG=$(aws s3api upload-part \
--bucket "$BUCKET" \
--key "$KEY" \
--part-number 1 \
--body part-1.bin \
--upload-id "$UPLOAD_ID" \
--query ETag \
--output text)
echo "$ETAG"A successful configuration command may return no output. Treat inspection as a separate required step.
Inspect the result
aws s3api list-parts \
--bucket "$BUCKET" \
--key "$KEY" \
--upload-id "$UPLOAD_ID" \
--query "Parts[].{Number:PartNumber,Size:Size,ETag:ETag}" \
--output tableRead the returned fields rather than assuming the write succeeded exactly as intended.
One tiny variation
aws s3api upload-part \
--bucket "$BUCKET" \
--key "$KEY" \
--part-number 1 \
--body replacement-part-1.bin \
--upload-id "$UPLOAD_ID"Uploading the same part number again replaces that part inside the unfinished upload.
Common mistake
Save the exact ETag returned for every part. Completing the upload requires the ordered part number and ETag pairs.
Cleanup
aws s3api abort-multipart-upload \
--bucket "$BUCKET" \
--key "$KEY" \
--upload-id "$UPLOAD_ID"
rm part-1.binAborting removes the uploaded part storage for this upload session.
Next, we will learn Complete an S3 multipart upload.