Better bucket name pending possible change to uuid for service primary

key.

Also small bugfix around file name and original file name
This commit is contained in:
Adam Shimali
2016-01-29 12:19:50 +00:00
parent 0dc6f7be1a
commit 5196436645
5 changed files with 22 additions and 17 deletions

View File

@@ -6,7 +6,7 @@ from boto3 import resource
def s3upload(service_id, filedata):
upload_id = str(uuid.uuid4())
s3 = resource('s3')
bucket_name = 'service-{}-notify'.format(service_id)
bucket_name = 'service-{}-{}-notify'.format(service_id, upload_id)
s3.create_bucket(Bucket=bucket_name)
contents = '\n'.join(filedata['data'])
key = s3.Object(bucket_name, upload_id)
@@ -16,7 +16,7 @@ def s3upload(service_id, filedata):
def s3download(service_id, upload_id):
s3 = resource('s3')
bucket_name = 'service-{}-notify'.format(service_id)
bucket_name = 'service-{}-{}-notify'.format(service_id, upload_id)
key = s3.Object(bucket_name, upload_id)
contents = key.get()['Body'].read().decode('utf-8')
return contents