Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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")
like image 764
Ciarán Avatar asked Sep 24 '13 10:09

Ciarán


People also ask

What is Boto 3 used for?

Boto3 makes it easy to integrate your Python application, library, or script with AWS services including Amazon S3, Amazon EC2, Amazon DynamoDB, and more.

What is S3 Boto?

Amazon Simple Storage Service (Amazon S3) is an object storage service that offers scalability, data availability, security, and performance. This section demonstrates how to use the AWS SDK for Python to access Amazon S3 services.

How do I connect my S3 to Boto3?

Setting up a client To access any AWS service with Boto3, we have to connect to it with a client. Here, we create an S3 client. We specify the region in which our data lives. We also have to pass the access key and the password, which we can generate in the AWS console, as described here.

What is the difference between Boto and Boto3?

Boto has become the official AWS SDK for Python. Boto versions include Boto, Boto3 and Botocore. Boto3 is the latest version of the SDK, providing support for Python versions 2.6. 5, 2.7 and 3.3.


1 Answers

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")
like image 127
shry Avatar answered Oct 04 '22 21:10

shry