Sam
Sam

Reputation: 63

How to Delete an S3 Object by ETag

Using AmazonS3 SDK how can we delete an S3 Object using the key(i.e. file name) and eTag for the object ?

We can get file by eTag leveraging below code

GetObjectRequest request = new GetObjectRequest(bucket, key);
request.setMatchingETagConstraints(Collections.singletonList(eTag));

do we have similar API to delete an Object from S3 ?

Upvotes: 1

Views: 1465

Answers (1)

NHol
NHol

Reputation: 2125

No, there is no setMatchingETagConstraints method for deleteobjectrequest. You will need to get the key first as you describe.

Upvotes: 1

Related Questions