diff options
Diffstat (limited to 'pbserver.py')
| -rwxr-xr-x | pbserver.py | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/pbserver.py b/pbserver.py index 5501f54..e7f190a 100755 --- a/pbserver.py +++ b/pbserver.py @@ -18,6 +18,9 @@ from subprocess import call, Popen, PIPE import simplejson as json BIN_IDENTIFY = "/usr/bin/identify" +from boto.s3.connection import S3Connection +from boto.s3.key import Key + try: DB = db.db () except Exception as e: @@ -49,21 +52,18 @@ def cleanup(filepath): sys.stderr.write(str(e)) raise -def s3move(filepath,objectname): - conn = s3.AWSAuthConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) - filedata = open(filepath, 'rb').read() - content_type = mimetypes.guess_type(filepath)[0] +def s3move(filename,objectname): try: - conn.put(BUCKET_NAME, objectname, s3.S3Object(filedata), - { - 'x-amz-acl': 'public-read', - 'Content-Type': content_type or 'text/plain', - 'x-amz-storage-class': 'REDUCED_REDUNDANCY' - } - ); + conn = S3Connection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, is_secure=False) + b = conn.get_bucket(BUCKET_NAME) + k = Key(b) + k.key = objectname + k.set_contents_from_filename(filename) + k.set_acl('public-read') + k.storage_class = 'REDUCED_REDUNDANCY' except Exception as e: - sys.stderr.write(str(e)) - raise + sys.stderr.write(str(e)); + raise(e) def insert_cmd (date, remote_addr, username, url, directory, oldfile, newfile, cmd, dataobj, tag): try: |
