Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
278 views
in Technique[技术] by (71.8m points)

amazon s3 - s3 per object expiry

I know how to expire objects in an S3 bucket using object expiration rules given a certain prefix, however for my purposes, I would like to set the expiry date programmatically on a per object basis.

The Java SDK seems to indicate that this is possible as it has a setExpirationTime method, however whenever I set an expiration Date using this method, nothing seems to happen and the object never expires. Additionally, looking at the object properties through the aws console, no expiry appears to be set.

Is per file expiration not supported ? / Are there any extra steps I need to do to get it to work ? / If per file expiration is not supported, is it possible to exclude a file that matches an expiration prefix from being expired ?

Thanks in advance!

question from:https://stackoverflow.com/questions/12185879/s3-per-object-expiry

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It doesn't look like per-object expiration is supported, but rather a per-bucket lifecycle configuration with up to 100 rules per configuration, as you have found.

A bucket has one lifecycle configuration. A lifecycle configuration can have up to 100 rules.

The lifetime value must be a nonzero positive integer. Amazon S3 calculates expiration time by adding the expiration period specified in the rule to the object creation time and rounding the resulting time to the next day midnight UTC.

If per file expiration is not supported, is it possible to exclude a file that matches an expiration prefix from being expired ?

It doesn't look like you can overlap rules, either.

Take care to ensure the rules don't overlap. For example, the following lifecycle configuration has a rule that sets objects with the prefix "documents" to expire after 30 days. The configuration also has another rule that sets objects with the prefix "documents/2011" to expire after 365 days. In this case, Amazon S3 returns an error message.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...