Search code examples
amazon-s3metadatalast-modified

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


I'm currently working with Amazon S3 and I am writing a program that uses the modified dates. I'm looking for a way 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?


Solution

  • 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.