Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting the versions of every file in an Amazon S3 bucket older than X days

I find it strange that after looking everywhere I don't find any tool to delete all the versions of a file older than X days (not the actual file) of a S3 bucket that has versioning enabled. I would believe this is a very common issue because without it the buckets with time would become huge.

Is there any existing solution (even commercial)?

If there is no ready made way, could you point me to some info or give me suggestions on how to code this myself in C#? I guess I have to use recursion for this kind of problem.

Thanks

like image 516
Durden81 Avatar asked Feb 29 '12 22:02

Durden81


1 Answers

If you use the amazon s3 API, you can do that. I use AmazonS3Client + DeleteObjectRequest method on amazon SDK:

http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/AmazonS3Client.html

http://docs.amazonwebservices.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/model/DeleteObjectRequest.html

Should really be straightforward.

Hope it helps

like image 116
Ademar Avatar answered Oct 22 '22 21:10

Ademar