Skip to content

Instantly share code, notes, and snippets.

@doobeh
Created November 6, 2012 19:42
Show Gist options
  • Save doobeh/4027001 to your computer and use it in GitHub Desktop.
Save doobeh/4027001 to your computer and use it in GitHub Desktop.
Quick S3 Example
def s3_upload(filename):
# Destination Filename
destination_filename = os.path.basename(filename)
# Connect to S3
conn = boto.connect_s3(app.config["S3_KEY"], app.config["S3_SECRET"])
b = conn.get_bucket(app.config["S3_BUCKET"])
# Upload the File
sml = b.new_key("/".join([app.config["S3_UPLOAD_DIRECTORY"],destination_filename]))
sml.set_contents_from_filename(filename)
# Set the file's permissions.
sml.set_acl(acl)
return destination_filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment