如何在不更改上次修改日期的情况下上传/下载到S3? [英] How to Upload/download to S3 without changing Last Modified date?
问题描述
我想使用boto3将文件上传和下载到S3,而又不更改其"LastModified"日期,因此可以随时查看内容的年代.每当我上载或下载文件时,该日期即为该操作的日期,而我丢失了修改内容的日期.
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')
其中fileObj是从分页器结果中获取的.我正在使用以下命令上传
where the fileObj is taken from a paginator result. I'm using the following command to upload
s3Client.upload_fileobj(data, bucket_name, destpath)
和以下内容下载文件:
s3Client.download_file(bucket_name, key, localPath)
如何停止上次修改日期的更改?
How can I stop the last modified date changing?
推荐答案
这是不可能的.
最后修改日期是由Amazon S3生成的,不能被覆盖.
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.
这篇关于如何在不更改上次修改日期的情况下上传/下载到S3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!