s5cmd icon indicating copy to clipboard operation
s5cmd copied to clipboard

Any way to "touch" files? (update last-modified date to reset Lifecycle policy timer)

Open GordonGustafson opened this issue 2 years ago • 1 comments

I've tried things like this to see if the LastModified time updates:

s5cmd cp --expires "2024-10-01T20:30:00Z"  's3://bucket/path/*' s3://bucket/path/

But I get this error:

 InvalidRequest: This copy request is illegal because it is trying to copy an object to itself without changing the object's metadata, storage class, website redirect location or encryption attributes. status code: 400

I can get the behavior I want with the AWS CLI like so:

aws s3 cp s3://bucket/path s3://bucket/path --recursive --metadata-directive REPLACE

I know I could just copy the data to another path and copy it back to reset the LastModified timestamp, but wondering if there's a better way with s5cmd. Thanks!

GordonGustafson avatar Sep 21 '23 21:09 GordonGustafson

Hi, thanks for mentioning this issue. I believe that what we need to do is add a new flag called metadataDirective to the cp command. Will work on a PR as soon as I can.

denizsurmeli avatar Sep 22 '23 06:09 denizsurmeli