自动删除Amazon S3中早于n天的对象(如何?)
我正在Amazon S3中存储许多图像, 使用ruby lib( http://amazon.rubyforge.org/)
I am storing many images in Amazon S3, using a ruby lib (http://amazon.rubyforge.org/)
我不在乎1周以上的照片,然后要释放S3中的空间,我必须删除这些照片.
I don't care the photos older than 1 week, then to free the space in S3 I have to delete those photos.
我知道有一种方法可以删除某个存储桶中的对象:
I know there is a method to delete the object in a certain bucket:
S3Object.delete 'photo-1.jpg', 'photos'
有没有一种方法可以自动删除早于一周的图像?
Is there a way to automatically delete the image older than a week ?
如果它不存在,我将不得不编写一个守护程序来实现:-(
If it does Not exist, I'll have to write a daemon to do that :-(
谢谢
更新:现在可以检查罗伯托的答案了.
UPDATE: now it is possible, check the Roberto's answer.
不幸的是,亚马逊没有提供基于一组特定条件的自动删除API.
Unfortunately, Amazon doesn't offer an API for automatic deletion based on a specific set of criteria.
您需要编写一个守护程序,该守护程序会遍历所有照片,并仅选择满足您条件的照片,然后将它们一张一张地删除.
You'll need to write a daemon that goes through all of the photos and and selects just those that meet your criteria, and then delete them one by one.