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

后端 未结 29 3717
逝去的感伤
逝去的感伤 2020-12-02 04:45

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 /. Is ther

29条回答
  •  爱一瞬间的悲伤
    2020-12-02 05:34

    You can just execute this cli command to get the total file count in the bucket or a specific folder

    Scan whole bucket

    aws s3api list-objects-v2 --bucket testbucket | grep "Key" | wc -l
    aws s3api list-objects-v2 --bucket BUCKET_NAME | grep "Key" | wc -l
    

    you can use this command to get in details

    aws s3api list-objects-v2 --bucket BUCKET_NAME
    

    Scan a specific folder

    aws s3api list-objects-v2 --bucket testbucket --prefix testfolder --start-after testfolder/ | grep "Key" | wc -l
    
    aws s3api list-objects-v2 --bucket BUCKET_NAME --prefix FOLDER_NAME --start-after FOLDER_NAME/ | grep "Key" | wc -l
    

提交回复
热议问题