Created
August 9, 2013 02:11
-
-
Save lardissone/6190624 to your computer and use it in GitHub Desktop.
upload file to s3
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
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