← All posts
2 min read

Complete an S3 multipart upload

#aws#cli#s3#storage
📑 On this page

Part 46 of AWS from Zero. This lesson keeps the scope to one S3 behavior you can verify from the terminal.

What we are learning

Completion sends the ordered part list back to S3. S3 concatenates those parts and creates the final object.

Before you run it

BUCKET="replace-with-your-private-demo-bucket"
KEY="large-demo.bin"
UPLOAD_ID="replace-with-an-active-upload-id"
ETAG_1='"replace-with-part-1-etag"'
ETAG_2='"replace-with-part-2-etag"'

Upload at least two parts first and preserve their ETags exactly, including any quoting required by your shell.

The command

cat > complete.json <<EOF
{
  "Parts": [
    {"ETag": $ETAG_1, "PartNumber": 1},
    {"ETag": $ETAG_2, "PartNumber": 2}
  ]
}
EOF
 
aws s3api complete-multipart-upload \
  --bucket "$BUCKET" \
  --key "$KEY" \
  --upload-id "$UPLOAD_ID" \
  --multipart-upload file://complete.json

A successful configuration command may return no output. Treat inspection as a separate required step.

Inspect the result

aws s3api head-object \
  --bucket "$BUCKET" \
  --key "$KEY" \
  --query "{Size:ContentLength,ETag:ETag,Parts:PartsCount}"

Read the returned fields rather than assuming the write succeeded exactly as intended.

One tiny variation

aws s3api list-multipart-uploads \
  --bucket "$BUCKET" \
  --prefix "$KEY"

The completed upload ID should no longer appear among incomplete uploads.

Common mistake

Parts must be listed in ascending order. Missing parts, stale ETags, or an aborted upload ID cause completion to fail.

Cleanup

aws s3 rm "s3://$BUCKET/$KEY"
rm complete.json

Delete the completed object and local manifest.

Next, we will learn Abort an incomplete S3 multipart upload.

Official AWS CLI reference