Created
November 6, 2012 19:42
-
-
Save doobeh/4027001 to your computer and use it in GitHub Desktop.
Quick S3 Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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