1

In a similar vein to this question, I'd like a way to check how much disk space an S3 bucket is using. But, I'd like to do it through the boto library in python rather than through a command-line script.

I looked through the documentation page and didn't see anything that might get the job done. Is there a way to do this or am I stuck shelling out?

Community
  • 1
  • 1
Valdogg21
  • 1,151
  • 4
  • 14
  • 24

1 Answers1

4

Since S3 is just a key/value store you need to calculate this manually. It doesn't have a concept of a filesystem that you can just query. So you'll want to do something like this:

import boto
s3 = boto.connect_s3()
bucket = s3.lookup('mybucketname')
total_bytes = 0
for key in bucket:
       total_bytes += key.size
print total_bytes
Bruce P
  • 19,995
  • 8
  • 63
  • 73