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

╄→尐↘猪︶ㄣ 提交于 2019-12-24 01:09:08

问题


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

fileObj.get('LastModified')

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

s3Client.upload_fileobj(data, bucket_name, destpath)

and the following to download the files:

s3Client.download_file(bucket_name, key, localPath)

How can I stop the last modified date changing?


回答1:


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.



来源:https://stackoverflow.com/questions/44187847/how-to-upload-download-to-s3-without-changing-last-modified-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!