Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
323caeb7
Commit
323caeb7
authored
Feb 11, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly pass around S3 interface
parent
01e8fe8d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
9 deletions
+5
-9
common/lib/xmodule/xmodule/open_ended_image_submission.py
+3
-8
common/lib/xmodule/xmodule/openendedchild.py
+2
-1
No files found.
common/lib/xmodule/xmodule/open_ended_image_submission.py
View file @
323caeb7
...
...
@@ -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
(
s
ettings
.
AWS_ACCESS_KEY_ID
,
settings
.
AWS_SECRET_ACCESS_KEY
)
bucketname
=
str
(
s
ettings
.
AWS_STORAGE_BUCKET_NAME
)
conn
=
S3Connection
(
s
3_interface
[
'access_key'
],
s3_interface
[
'secret_access_key'
]
)
bucketname
=
str
(
s
3_interface
[
'storage_bucket_name'
]
)
bucket
=
conn
.
create_bucket
(
bucketname
.
lower
())
k
=
Key
(
bucket
)
...
...
common/lib/xmodule/xmodule/openendedchild.py
View file @
323caeb7
...
...
@@ -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."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment