s3 storage, stop creating bucket repeatedly

This commit is contained in:
James Turk 2012-02-21 16:25:51 -05:00
parent 9ef3a82d75
commit 211e40e211

View File

@ -8,11 +8,11 @@ class S3Storage(object):
def __init__(self, kernel): def __init__(self, kernel):
self.s3conn = boto.connect_s3(settings.AWS_KEY, settings.AWS_SECRET) self.s3conn = boto.connect_s3(settings.AWS_KEY, settings.AWS_SECRET)
self.bucket = self.s3conn.create_bucket(settings.AWS_BUCKET)
def put(self, tracked_doc, data, content_type): def put(self, tracked_doc, data, content_type):
""" upload the document to S3 """ """ upload the document to S3 """
bucket = self.s3conn.create_bucket(settings.AWS_BUCKET) k = boto.s3.key.Key(self.bucket)
k = boto.s3.key.Key(bucket)
k.key = tracked_doc['_id'] k.key = tracked_doc['_id']
headers = {'x-amz-acl': 'public-read', headers = {'x-amz-acl': 'public-read',
'Content-Type': content_type} 'Content-Type': content_type}