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")
Boto3 makes it easy to integrate your Python application, library, or script with AWS services including Amazon S3, Amazon EC2, Amazon DynamoDB, and more.
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.
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.
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.
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")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With