我正在使用 python 和 boto 从 amazon S3 获取文件。我正在使用这种格式上传:year/month/FileNameYYYYMMdd.hhmmss.zip
我的问题是我不知道文件的时间 (hhmmss)。有办法得到吗?例如:
bucket = awsCnx.get_bucket(bucketName)
directory = 'year/month/FileNameYYYYMMdd.*.zip'
bucket.list(prefix=directory)
请您参考如下方法:
来自博托source-code :
def list(self, prefix='', delimiter='', marker='', headers=None,
encoding_type=None):
"""
...
:type prefix: string
:param prefix: allows you to limit the listing to a particular
prefix. For example, if you call the method with
prefix='/foo/' then the iterator will only cycle through
the keys that begin with the string '/foo/'.
...
您可以在 docs 中阅读更多相关信息
所以我看不出为什么不完全按照您编写的方式实现它,只对声明进行微小的更改:
directory = 'year/month/FileNameYYYYMMdd'
(当然用正确的日期替换日期模式)。
