4

My code to delete the objects look like this:


const s3 = new AWS.S3({
    endpoint: spaceEndpoint,
    accessKeyId,
    secretAccessKey,
})

const params = {
    Bucket: bucketName,
    Delete: {
        Objects: assetsToDelete,
    },
}
try {
    const res1 = await s3.deleteObjects(params).promise()
}catch(e){
    console.log(e)
}

value of assetsToDelete is

  {
    Key: 'userId/folderName/object1'
  },
  {
    Key: 'userId/folderName/object2'
  }
]

But I'm getting an error:

InvalidArgument: Invalid argument.
   ErrorSTACK {
  code: 'InvalidArgument',
  region: null,
  time: 2021-02-12T20:30:42.055Z,
  requestId: null,
  extendedRequestId: undefined,
  cfId: undefined,
  statusCode: 400,
  retryable: false,
  retryDelay: 81.1455003388468
}

The above configuration works fine for upload and listing objects. I'm trying to delete from a gcp bucket.

6
  • 3
    I don't think Google Cloud Storage supports this yet, but you can delete objects individually. issuetracker.google.com/issues/162653700 is tracking this. Commented Feb 12, 2021 at 21:30
  • 1
    Additionally, cloud.google.com/storage/docs/migrating#methods-comparison may be helpful in comparing the two surfaces and making calls. Commented Feb 12, 2021 at 21:35
  • @ChrisWilcox thank you for this. I used s3.deleteObject instead of s3.deleteObjects. Commented Feb 14, 2021 at 16:48
  • Hello @VikasKundu, was the issue now resolved? Commented Feb 15, 2021 at 2:02
  • 1
    @ChrisWilcox I upvoted the comment that helped OP with the issue. Please post it as an answer. Commented Feb 17, 2021 at 1:03

1 Answer 1

4

As of posting, Google Cloud Storage doesn't support Multi-object Delete.

That said, you can delete individual objects. If you would like to track the addition of this, you can view https://issuetracker.google.com/issues/162653700

Additionally, cloud.google.com/storage/docs/migrating#methods-comparison may be helpful in comparing the two surfaces and making calls as you continue on your migration from S3 to Google Cloud Storage

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.