Skip to content

S3 bucket File with 0 Size #7283

Answered by tim-finnigan
ssk199441 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ssk199441 there may not be a command specifically for that use case but you can find some suggestions here: https://stackoverflow.com/questions/10832777/how-to-find-zero-byte-files-in-amazon-s3

For example using the CLI:
aws s3api list-objects --bucket $BUCKET --prefix $PREFIX --output json --query 'Contents[?Size==`0`]

Or using an SDK:

const getBucketFileSize = async function () {
  try {
    const response = await s3
      .listObjectsV2({
        Bucket: //Bucket-name,
        Prefix: //Provide Bucket Prefix if available,
      })
      .promise();

    response.Contents.map(item=>{
         if(item.Size===0){
            console.log(item)
         }
    })
  } catch (e) {
    console

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aBurmeseDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants