Is there a way to query an S3 bucket and get the count?

I’m using ExAws and I am trying to get the count of all images (ex, gif, png, etc…) in a bucket. There seems to be away to get a summary via the CLI, but I don’t see any obvious way to do this in the documentation.

Here’s a way to get the summary via CLI: file - How can I tell how many objects I've stored in an S3 bucket? - Stack Overflow

Edit: it seems the only way to do this is making multiple API calls with max_count.

Yeah S3 does not offer an efficient API to do a count with. I highly recommend storing metadata about S3 records somewhere else like a database so that you can do those queries there.

2 Likes