Skip to content

Instantly share code, notes, and snippets.

@lardissone
Created August 9, 2013 02:11
Show Gist options
  • Save lardissone/6190624 to your computer and use it in GitHub Desktop.
Save lardissone/6190624 to your computer and use it in GitHub Desktop.
upload file to s3
from boto.s3.connection import S3Connection, Key
import glob
import os
filelist = filter(os.path.isfile, glob.glob('/tmp/motion/*.jpg'))
filelist.sort(key=lambda x: os.path.getmtime(x))
filename = filelist[-1]
conn = S3Connection('', '')
bucket = conn.get_bucket('securaspi')
k = Key(bucket)
k.key = os.path.basename(filename)
k.set_metadata("Content-Type", 'image/jpeg')
k.set_contents_from_filename(filename)
k.set_acl("public-read")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment