How to Upload/download to S3 without changing Last Modified date?


I want to upload and download files to S3 using boto3 without changing their “LastModified” date so I can keep tabs on the age of the contents. Whenever I upload or download a file it takes on the date of this operation and I lose the date that the contents were modified.

I’m looking at the timestamp of the files using

where the fileObj is taken from a paginator result. I’m using the following command to upload

and the following to download the files:

How can I stop the last modified date changing?


This is not possible.

The Last Modified Date is generated by Amazon S3 and cannot be overridden.

If you wish to maintain your own timestamps, you could add some User-Define Metadata and set the value yourself.

Leave a Reply