try dahan
try dahan

Reputation: 113

Set AWS S3 expiration for specific file

I read the PHP AWS SDK Documentation at https://docs.aws.amazon.com/aws-sdk-php/v2/api/class-Aws.S3.S3Client.html about the putBucketLifecycleConfiguration method and I couldn't find a way to set an expiration date for a single file and not a bucket. Is that possible? I want to upload files and have them removed after 24 hours.

Upvotes: 2

Views: 1998

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270294

The Lifecycle policies apply to a PATH. They are typically used for the whole bucket or a sub-directory.

It is not possible to specify a lifecycle policy on the object itself, but you could specify the path as the full name of the object, so that they lifecycle policy works only on that one object. (I haven't tried it, but it theoretically should work.)

Upvotes: 1

Related Questions