无法使用 Python Boto-2.48 为 AWS S3 对象 get_metadata

Not able to get_metadata for AWS S3 object using Python Boto-2.48

我正在尝试 get_metadata() 我已在 s3 存储桶中的所有项目(对象)上设置。 get_metadata 调用 return None.

我正在使用 Python 2.7 和 Boto 2.48。以下是我的代码。

    for key in bucket:

    key = bucket.get_key(key.name)
    print key
    if key is not None:
        print key.name, key.get_metadata('Cache-Control'), key.get_metadata('Content-Type'), key.get_metadata('Expires')

输出:

images/xyz.jpg None None None

我已经尝试过以下link中提到的建议, Boto s3 get_metadata https://github.com/boto/boto/issues/570

如果我在这里遗漏了什么,请提出建议!

以下对我有用。

for key in bucket:

    key = bucket.get_key(key.name)

    if key is not None:
        print key.name, key.cache_control, key.content_type, key.expires

有趣的是,documentation 中没有提到 key.expires,但它对我有用。