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

后端 未结 29 3791
逝去的感伤
逝去的感伤 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:30

    There is an easy solution with the S3 API now (available in the AWS cli):

    aws s3api list-objects --bucket BUCKETNAME --output json --query "[length(Contents[])]"
    

    or for a specific folder:

    aws s3api list-objects --bucket BUCKETNAME --prefix "folder/subfolder/" --output json --query "[length(Contents[])]"
    

提交回复
热议问题