Skip to content

Instantly share code, notes, and snippets.

@64lines
Last active January 3, 2016 05:49
Show Gist options
  • Save 64lines/8418760 to your computer and use it in GitHub Desktop.
Save 64lines/8418760 to your computer and use it in GitHub Desktop.
Upload Files to Amazon
import os
import boto
from boto.s3.key import Key
bucket_name = os.getenv("AWS_STORAGE_BUCKET_NAME")
conn = boto.connect_s3()
bucket = conn.get_bucket(bucket_name)
k = Key(bucket)
key_name = 'test_file.csv'
k.key = key_name
k.set_contents_from_string('title;data\ntest;test_data')
k.get_contents_as_string()
url = k.generate_url(expires_in=(24 * 60 * 60))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment