diff --git a/common/lib/xmodule/xmodule/open_ended_image_submission.py b/common/lib/xmodule/xmodule/open_ended_image_submission.py index 66500146ed..88921c1429 100644 --- a/common/lib/xmodule/xmodule/open_ended_image_submission.py +++ b/common/lib/xmodule/xmodule/open_ended_image_submission.py @@ -13,11 +13,6 @@ from urlparse import urlparse import requests from boto.s3.connection import S3Connection from boto.s3.key import Key -#TODO: Settings import is needed now in order to specify the URL and keys for amazon s3 (to upload images). -#Eventually, the goal is to replace the global django settings import with settings specifically -#for this module. There is no easy way to do this now, so piggybacking on the django settings -#makes sense. -from django.conf import settings import pickle import logging import re @@ -221,7 +216,7 @@ def run_image_tests(image): return success -def upload_to_s3(file_to_upload, keyname): +def upload_to_s3(file_to_upload, keyname, s3_interface): ''' Upload file to S3 using provided keyname. @@ -237,8 +232,8 @@ def upload_to_s3(file_to_upload, keyname): #im.save(out_im, 'PNG') try: - conn = S3Connection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY) - bucketname = str(settings.AWS_STORAGE_BUCKET_NAME) + conn = S3Connection(s3_interface['access_key'], s3_interface['secret_access_key']) + bucketname = str(s3_interface['storage_bucket_name']) bucket = conn.create_bucket(bucketname.lower()) k = Key(bucket) diff --git a/common/lib/xmodule/xmodule/openendedchild.py b/common/lib/xmodule/xmodule/openendedchild.py index c83b0f0ea3..6e97ad6c9c 100644 --- a/common/lib/xmodule/xmodule/openendedchild.py +++ b/common/lib/xmodule/xmodule/openendedchild.py @@ -100,6 +100,7 @@ class OpenEndedChild(object): self.display_name = static_data['display_name'] self.accept_file_upload = static_data['accept_file_upload'] self.close_date = static_data['close_date'] + self.s3_interface = static_data['s3_interface'] # Used for progress / grading. Currently get credit just for # completion (doesn't matter if you self-assessed correct/incorrect). @@ -319,7 +320,7 @@ class OpenEndedChild(object): try: image_data.seek(0) - success, s3_public_url = open_ended_image_submission.upload_to_s3(image_data, image_key) + success, s3_public_url = open_ended_image_submission.upload_to_s3(image_data, image_key, self.s3_interface) except: log.exception("Could not upload image to S3.")