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 in AWS by akhtar
• 24,570 points

1 answer to this question.

0 votes


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 by MD
• 55,020 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
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,150 points
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket.….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 57,640 points
0 votes
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
• 57,640 points
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,770 points
0 votes
2 answers
+1 vote
1 answer