Is there a way to touch() a file in Amazon S3?

Ron van der Heijden picture Ron van der Heijden · Nov 19, 2012 · Viewed 14.4k times · Source

I'm currently working with Amazon S3 and I am writing a program that check the modified dates.

What I need is a solution to edit the modified dates.

I could loop trough all the files and save them as they are, but this sounds like a bad solution.

In PHP there is this function touch().

Does anyone know a solution, or has the same problem?

Answer

Jason picture Jason · May 27, 2016

In response to @Daniel Golden's comment on @tkotisis answer. It looks like at least the AWS CLI tools do not let you copy an item on to itself. You can however 'force' a copy by updating the metadata.

$ aws s3 cp --metadata '{"touched":"now"}' s3://path/to/object s3://path/to/object

This recreates the object (downloads to the caller and reuploads it) replacing its content, owner and metadata. This will also trigger any attached Lambda events.