A few questions regarding Object Storage lifecycle policies
A few questions regarding lifecycle policies on Object Storage:
- Can I set a life cycle policy to automatically delete partially completed or failed uploads within a day or two?
- Can I set a lifecycle policy for completed uploads that never deletes those files?
- Can I set a lifecycle policy for a single file?
While I'm no expert on Lifecycle policies for Object Storage, I've set up policies for a few of my buckets previously. If you haven't seen it yet, we have a great guide that covers setting lifecycle policies: How To Manage Objects with Lifecycle Policies. I highly recommend reading through that guide! As for your questions, I'll break them down below:
Yes, you can delete failed uploads after a day or two through setting AbortIncompleteMultipartUpload and its child DaysAfterInitiation. In the following example (taken from our guide) failed uploads are deleted after 3 days. See Additional Actions section of the aforementioned guide.
... <AbortIncompleteMultipartUpload> <DaysAfterInitiation>3</DaysAfterInitiation> </AbortIncompleteMultipartUpload> ...
To keep objects indefinitely, don't set the Expiration directive in a lifecycle policy. This directive will automatically delete objects after a certain number of days, which sounds like something you don't want.
Lifecycle policies are set on a per bucket level. I'm not aware of setting them per-file, but others may know of a workaround that I do not.
And just for your own knowledge, lifecycle policies can be managed through the command line through s3cmd or Cyberduck. You'll have more control using raw XML through s3cmd, but Cyberduck may be an easier tool depending on your experience.