I have searched this topic on aws docs/several websites/stackoverflow and was not able to find any answer.
I want to delete all the versions of an object in versioned s3 bucket in a single call.
DeleteObjectsAsync
request.Is there any way to delete all the versions of an object, whether it has delete marker or not, in a single call to AWS using S3's .net SDK ?
I did the same for one of my clients. We were using S3 to store many versions of a single file. After surfing the web pretty much, I was not able to find any method. The best approach is to just loop over the S3 file versions. Helpful steps:
Note: I observed a weird behavior of S3 where after deleting all the versions of an object, I sometimes found a Delete Marker being created. Well of course if you delete the file from S3 console, you get a delete marker. But in my case, doing it though NodeJs, I found that only some times. So you need to handle that as well in your code. This is how I did it in NodeJS
if (data.Deleted.DeleteMarker) {
console.log('Found delete marker', data.Deleted.DeleteMarker);
//Handle here to delete the deleteMarker
}
Thanks, Upvote if it helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With