Ciarán
Ciarán

Reputation: 773

Boto s3 get_metadata

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

enter image description here

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")

Upvotes: 11

Views: 10435

Answers (1)

shry
shry

Reputation: 1902

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")

Upvotes: 20

Related Questions