使用Boto获取S3对象的最后修改日期时间 [英] Getting S3 objects' last modified datetimes with boto

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

问题描述

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

I'm writing a Python script that uploads files to S3 using Boto. 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.

推荐答案

下面是一段Python/boto代码,这些代码将打印存储桶中所有键的last_modified属性:

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对象的最后修改日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆