Amazon S3 Aws - get_bucket method in boto python API

This example shows how to get a single key from a bucket and then write that key to a file.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
from boto.s3.connection import S3Connection from boto.s3.key import Key # Get connection using Amazon secret and access keys conn = S3Connection('<aws secret key>', '<aws access key>') # Get the bucket with name 'bucketname' bucket = conn.get_bucket('bucketname') # Get the key reference to file 'picture.jpg' key = bucket.get_key("picture.jpg") # Open file in write mode fp = open ("picture.jpg", "w") # Set the reference to file key.get_file (fp)

Other Steps and Solutions

If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus