Skip to content

S3

MultiPart Upload

Documentation

# Split the File

export BUCKET=fsantos-vmware-ova-templates
export FILE=aws.ova

split -b <bytes> <file>

# Upload
aws s3api create-multipart-upload --bucket ${BUCKET} --key ${FILE}

export UPLOAD_ID=

# Repeat to all parts - Changing the body and increase part number
aws s3api upload-part --bucket ${BUCKET} --key ${FILE} --part-number 1 --body <file-part1> --upload-id ${UPLOAD_ID}

# List all uploaded parts and get ETags
aws s3api list-parts --bucket ${BUCKET} --key ${FILE} --upload-id ${UPLOAD_ID}

# Create fileparts.json with all Etags

# Complete Multipart upload

aws s3api complete-multipart-upload --multipart-upload file://fileparts.json --bucket ${BUCKET} --key ${FILE} --upload-id ${UPLOAD_ID}
  • filepats.json example
{
    "Parts": [{
        "ETag": "\"example8be9a0268ebfb8b115d4c1fd3\"",
        "PartNumber":1
    },

    ....

    {
        "ETag": "\"example246e31ab807da6f62802c1ae8\"",
        "PartNumber":4
    }]
}