Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
Created June 15, 2015 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthuralvim/3fb534a8e470f4e4d5a7 to your computer and use it in GitHub Desktop.
Save arthuralvim/3fb534a8e470f4e4d5a7 to your computer and use it in GitHub Desktop.
Working with files in AWS S3
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment