How can I tell how many objects I've stored in an S3 bucket?

Unless I'm missing something, it seems that none of the APIs I've looked at will tell you how many objects are in an S3 bucket / folder(prefix). Is there any way to get a count?

Answers 1

  • There is no way, unless you

    1. list them all in batches of 1000 (which can be slow and suck bandwidth - amazon seems to never compress the XML responses), or

    2. log into your account on S3, and go Account - Usage. It seems the billing dept knows exactly how many objects you have stored!

    Simply downloading the list of all your objects will actually take some time and cost some money if you have 50 million objects stored.

    Also see this thread about StorageObjectCount - which is in the usage data.

    An S3 API to get at least the basics, even if it was hours old, would be great.


Related Articles