How to measure the total size of an S3 bucket using python

0 votes

Hi Guys,

I have my s3 buckets in aws. How can I measure the total size of s3 bucket using python?

Thank You

Apr 15, 2020 in AWS by akhtar
• 38,260 points
5,685 views

1 answer to this question.

0 votes

Hi@akhtar,

You can do this tasks using Boto. It allows the Bucket object to be used as an iterator. Use this bellow code to measure size of s3 bucket.

import boto
s3 = boto.connect_s3()
bucket = s3.lookup('mybucketname')
total_bytes = 0
for key in bucket:
           total_bytes += key.size
print total_bytes
answered Apr 15, 2020 by MD
• 95,460 points

Related Questions In AWS

0 votes
2 answers

How to display just the name of files using aws s3 ls command?

aws s3 ls s3://<your_bucket_name>/ | awk '{print ...READ MORE

answered Mar 17, 2019 in AWS by anonymous
22,322 views
0 votes
1 answer

How to download the latest file in a S3 bucket using AWS CLI?

You can use the below command $ aws ...READ MORE

answered Sep 6, 2018 in AWS by Archana
• 4,170 points
19,888 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,020 points
6,016 views
–1 vote
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,020 points
5,234 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,820 points
2,885 views
0 votes
2 answers
0 votes
1 answer

How to get the size of an Amazon S3 bucket?

Hi@akhtar, You can use AWS CLI to perform ...READ MORE

answered Oct 5, 2020 in AWS by MD
• 95,460 points
1,631 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP