1

I am trying to delete multiple objects at once using boto3 using this.

client.delete_objects(Bucket=bucket_name, Delete={'Objects':[{'Key':'satinder/tmp/img1.jpg'},{'Key':'satinder/tmp/img2.jpg'}]})

The response I get says deleted both the keys, but only one key was present on s3. Part of the response:

'Deleted': [{'Key': 'satinder/tmp/img1.jpg'}, {'Key': 'satinder/tmp/img2.jpg'}]

I want to know if there is any way I can know which all objects were really deleted and for which all deletion failed(because it was not present there)?

Thanks.

1 Answers1

2

This is how the boto3 delete_objects method works, the behavior is described in the documentation:

Note that if the object specified in the request is not found, Amazon S3 returns the result as deleted.

If you need to find whether these objects exist before deleting them, you can use the head_object method on each object first.

mattficke
  • 727
  • 4
  • 9