Store compressed file in AWS S3 bucket using python.

Charith Prasanna
1 min readNov 2, 2021

--

AWS S3 stand for Amazon Simple Storage Service. Programmers can use Amazon S3 to store and retrieve any amount of data at any time. As a new member Amazon allows you to 5GB free space , 2,000 PUT requests, 20,000 GET requests and 15 GB of data transfer.

Here we discussed how to compress a object using python and put it into S3.Why we need to compress objects and store them into the s3 bucket? If we use cloudfront like services,when we want to access objects in s3 bucket using cloudfront , it cannot have more than 10Mb payload.Because of that better to compress the object and put it into the S3.

How we do this in python?

import boto3 -> need this library to access the AWS resources.

s3client = boto3.client(‘s3’) -> build the S3 client request.

Here line 5 ContentType need to be define corrently according to the what you going to store.

line 6 ContentEncoding type is the important thing, it must be defined as ‘gzip’.

I think this article might help if anyone interested with compress objects and store in s3.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Charith Prasanna
Charith Prasanna

Written by Charith Prasanna

Senior Software Engineer | University Of Moratuwa | Sysco LABS Sri Lanka | Backend Developer

No responses yet

Write a response