对象的上次修改日期时间

对象的上次修改日期时间

本文介绍了使用 boto 获取 S3 对象的上次修改日期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 Python 脚本,该脚本使用 boto 库将文件上传到 S3.我只想上传更改过的文件(我可以通过他们的上次修改"日期时间检查),但我找不到 Boto API 端点来获取上次修改日期.

解决方案

以下是 Python/boto 代码片段,用于打印存储桶中所有键的 last_modified 属性:

>>>进口博托>>>s3 = boto.connect_s3()>>>桶 = s3.lookup('mybucket')>>>对于桶中的密钥:打印 key.name、key.size、key.last_modifiedindex.html 13738 2012-03-13T03:54:07.000Zmarkdown.css 5991 2012-03-06T18:32:43.000Z>>>

I'm writing a Python script that uploads files to S3 using boto librairy. I only want to upload changed files (which I can check by their "last modified" datetimes), but I can't find the Boto API endpoint to get the last modified date.

解决方案

Here's a snippet of Python/boto code that will print the last_modified attribute of all keys in a bucket:

>>> import boto
>>> s3 = boto.connect_s3()
>>> bucket = s3.lookup('mybucket')
>>> for key in bucket:
       print key.name, key.size, key.last_modified
index.html 13738 2012-03-13T03:54:07.000Z
markdown.css 5991 2012-03-06T18:32:43.000Z
>>>

这篇关于使用 boto 获取 S3 对象的上次修改日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 08:24