I am searching my s3 bucket and I would like to know how can I check total number of objects (files) I have uploaded inside particular S3 Bucket on amazon web server? I am looking for easy solution here.
Here are some ways to get total number of objects stored in AWS S3.
Using S3 API
aws s3api list-objects --bucket BUCKETNAME --output json --query "[length(Contents[])]"
For a specific folder
aws s3api list-objects --bucket BUCKETNAME --prefix "folder/subfolder/" --output json --query "[length(Contents[])]"
Using AWS CLI
aws s3 ls s3://bucketName/path/ --recursive --summarize | grep "Total Objects:"
Total Objects: 4023
Using S3 command
s3cmd ls -r s3://logs.mybucket/subfolder/ > listing.txt
You can use any of the above method, depending on your need.
You can also use --summarize
switch which includes bucket summary information
Here is the example using amazon CLI
aws s3 ls s3://bucketName/path/ --recursive --summarize | grep "Total Objects:"
Total Objects: 7235
Thanks
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly