Boto s3 get_metadata

て烟熏妆下的殇ゞ 提交于 2020-01-13 08:04:51

问题


Trying to get meta_data that i have set on all my items in an s3 bucket. Which can be seen in the screenshot and below is the code I'm using. The two get_metadata calls return None. Any idea's

boto.Version '2.5.2'

amazon_connection = S3Connection(ec2_key, ec2_secret)
  bucket = amazon_connection.get_bucket('test')
  for key in bucket.list():
    print " Key %s " % (key)
    print key.get_metadata("company")
    print key.get_metadata("x-amz-meta-company")

回答1:


bucket.list() does not return metadata. try this instead:

for key in bucket.list():
   akey = bucket.get_key(key.name)
   print akey.get_metadata("company")


来源:https://stackoverflow.com/questions/18979199/boto-s3-get-metadata

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!