Can files uploaded to Amazon S3 be automatically deleted after a few days?
1 answer
Your file path is nothing more than a prefix in S3. So, if you have a structure like this:
/
|
+--folder1
|
+--folder2
|
+--folder3
| |
| +--foo.png
| |
| +--foo2.png
|
+--bar.png
And you want your rule to only apply to foo.png, set it to "folder1 / folder3 / foo.png" (there will only be one file matching the "full name" prefix in your bucket).
But keep in mind the limits on the number of rules. From Expiry Documents :
To set the expiration of objects, you add a lifecycle configuration to your bucket, which describes the lifetimes of various objects in your bucket. A lifecycle configuration can contain up to 100 rules. Each rule identifies an object prefix and lifetime for objects starting with that prefix. The lifetime is the number of days since creation when you want to delete an object.
+5
source to share