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
0c0a8971
Commit
0c0a8971
authored
Jan 30, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on uploading image submission to S3
parent
d06f5f77
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
common/lib/xmodule/xmodule/open_ended_image_submission.py
+3
-3
common/lib/xmodule/xmodule/openendedchild.py
+22
-1
No files found.
common/lib/xmodule/xmodule/open_ended_image_submission.py
View file @
0c0a8971
...
...
@@ -87,7 +87,7 @@ def run_image_tests(image):
image_properties
=
ImageProperties
(
image
)
return
image_properties
.
run_tests
()
def
upload_to_s3
(
string
_to_upload
,
keyname
):
def
upload_to_s3
(
file
_to_upload
,
keyname
):
'''
Upload file to S3 using provided keyname.
...
...
@@ -101,8 +101,8 @@ def upload_to_s3(string_to_upload, keyname):
k
=
Key
(
bucket
)
k
.
key
=
keyname
k
.
set_metadata
(
"Content-Type"
,
'images/png'
)
k
.
set_contents_from_
string
(
string
_to_upload
)
k
.
set_metadata
(
'filename'
,
file_to_upload
.
name
)
k
.
set_contents_from_
file
(
file
_to_upload
)
public_url
=
k
.
generate_url
(
60
*
60
*
24
*
365
)
# URL timeout in seconds.
return
True
,
public_url
...
...
common/lib/xmodule/xmodule/openendedchild.py
View file @
0c0a8971
...
...
@@ -27,6 +27,8 @@ import open_ended_image_submission
from
datetime
import
datetime
from
PIL
import
Image
log
=
logging
.
getLogger
(
"mitx.courseware"
)
# Set the default number of max attempts. Should be 1 for production
...
...
@@ -281,7 +283,26 @@ class OpenEndedChild(object):
@return:
"""
success
=
False
image_ok
=
run_image_checks
(
image
)
image
=
Image
.
open
(
image_data
)
try
:
image_ok
=
open_ended_image_submission
.
run_image_tests
(
image
)
success
=
True
except
:
pass
if
success
:
image_key
=
image_data
.
name
+
datetime
.
now
()
.
strftime
(
"
%
Y
%
m
%
d
%
H
%
M
%
S"
)
try
:
success
,
public_url
=
open_ended_image_submission
.
upload_to_s3
(
image_data
,
image_key
)
success
=
True
except
:
pass
...
...
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