DEV Community

Cover image for How To Configure Multipart Upload to S3 Bucket using AWS CLI
Thu Kha Kyawe
Thu Kha Kyawe

Posted on • Edited on

How To Configure Multipart Upload to S3 Bucket using AWS CLI

[!Note]
This lab needs to install AWS CLI first. If you don't know how to install it, please follow the instructions of this guideline . After finished installation, you can proceed the following guideline;

  • Type in terminal
aws --version
Enter fullscreen mode Exit fullscreen mode

  • Type in terminal
aws configure
Enter fullscreen mode Exit fullscreen mode
  • Fill information with your information

  • AWS Access Key ID [None]:

  • AWS Secret Access Key [None]:

  • Default region name [None]:

  • Default output format [None]:

  • Type in terminal

ll -h
Enter fullscreen mode Exit fullscreen mode
  • There is video file which has 432 MB

  • Go to S3 from AWS Management Console

  • Write Name at Bucket name

  • Click Create Bucket

  • Type in Terminal
split -b 200000000 video.mp4
Enter fullscreen mode Exit fullscreen mode
ls -h
Enter fullscreen mode Exit fullscreen mode

  • Type in terminal
aws s3api create-multipart-upload --bucket multipart-lab --key video.mp4 
Enter fullscreen mode Exit fullscreen mode

  • Save UploadID in Notepad.It will use later. It will be like this.

Fwy8LKON1Bxla9wGFeZR0DfOn3wOxq9AMNO5cFxP8sjvmwXUOV8_vUO4DS93B4ZXkwcurb9otrmZgsl6yEV5ChsM5DrSO8SENki9L0NzZgHx0k_qY7sO4DPf4ErkHTD4LtxjKlzAHUJYdW14jI22Gg--

  • Type in terminal
aws s3api upload-part --bucket multipart-lab --key video.mp4 --part-number 1 --body xaa --upload-id Fwy8LKON1Bxla9wGFeZR0DfOn3wOxq9AMNO5cFxP8sjvmwXUOV8_vUO4DS93B4ZXkwcurb9otrmZgsl6yEV5ChsM5DrSO8SENki9L0NzZgHx0k_qY7sO4DPf4ErkHTD4LtxjKlzAHUJYdW14jI22Gg--
Enter fullscreen mode Exit fullscreen mode
  • You will see like this and copy ETag Information to Notepad

  • Type in terminal
aws s3api upload-part --bucket multipart-lab --key video.mp4 --part-number 2 --body xab --upload-id Fwy8LKON1Bxla9wGFeZR0DfOn3wOxq9AMNO5cFxP8sjvmwXUOV8_vUO4DS93B4ZXkwcurb9otrmZgsl6yEV5ChsM5DrSO8SENki9L0NzZgHx0k_qY7sO4DPf4ErkHTD4LtxjKlzAHUJYdW14jI22Gg--
Enter fullscreen mode Exit fullscreen mode
  • You will see like this and copy ETag Information to Notepad

  • Type in terminal
aws s3api upload-part --bucket multipart-lab --key video.mp4 --part-number 3 --body xac --upload-id Fwy8LKON1Bxla9wGFeZR0DfOn3wOxq9AMNO5cFxP8sjvmwXUOV8_vUO4DS93B4ZXkwcurb9otrmZgsl6yEV5ChsM5DrSO8SENki9L0NzZgHx0k_qY7sO4DPf4ErkHTD4LtxjKlzAHUJYdW14jI22Gg-- 
Enter fullscreen mode Exit fullscreen mode
  • You will see like this and copy ETag Information to Notepad

alt text

  • Type in terminal
aws s3api list-parts --bucket multipart-lab --key video.mp4 --upload-id Fwy8LKON1Bxla9wGFeZR0DfOn3wOxq9AMNO5cFxP8sjvmwXUOV8_vUO4DS93B4ZXkwcurb9otrmZgsl6yEV5ChsM5DrSO8SENki9L0NzZgHx0k_qY7sO4DPf4ErkHTD4LtxjKlzAHUJYdW14jI22Gg--
Enter fullscreen mode Exit fullscreen mode
  • You will see like this

  • Make the json file by using the following example json and replace with ETag Information
{
    "Parts": [{
        "ETag": "example8be9a0268ebfb8b115d4c1fd3",
        "PartNumber":1
    },

    ....

    {
        "ETag": "example246e31ab807da6f62802c1ae8",
        "PartNumber":4
    }]
}
Enter fullscreen mode Exit fullscreen mode

  • Type in terminal
aws s3api complete-multipart-upload --multipart-upload file://multipart.json --bucket multipart-lab --key video.mp4 --upload-id Fwy8LKON1Bxla9wGFeZR0DfOn3wOxq9AMNO5cFxP8sjvmwXUOV8_vUO4DS93B4ZXkwcurb9otrmZgsl6yEV5ChsM5DrSO8SENki9L0NzZgHx0k_qY7sO4DPf4ErkHTD4LtxjKlzAHUJYdW14jI22Gg-- 
Enter fullscreen mode Exit fullscreen mode
  • You will see like this information

  • Click Refresh

  • You will see video.mp4 like this

  • Click Management and Create lifecycle rule

  • Write rule name at Lifecycle rule name and click I acknowledge that this rule will apply to all objects in the bucket.

  • Select Delete expired object delete markers or incomplete multipart uploads

  • Select Delete incomplete multipart uploads and Choose 1 at Number of days

  • Click Create Rule


Resources & Next Steps

  • πŸ“¦ Full Code Repository: AWS Learning Labs - Get the complete, working code from this post
  • πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
  • πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
  • πŸ’Ό Let's Connect: Linkedin - I'd love to connect with you

Top comments (0)