Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
0c0a8971
Commit
0c0a8971
authored
12 years ago
by
Vik Paruchuri
Browse files
Options
Downloads
Patches
Plain Diff
Work on uploading image submission to S3
parent
d06f5f77
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/open_ended_image_submission.py
+3
-3
3 additions, 3 deletions
common/lib/xmodule/xmodule/open_ended_image_submission.py
common/lib/xmodule/xmodule/openendedchild.py
+22
-1
22 additions, 1 deletion
common/lib/xmodule/xmodule/openendedchild.py
with
25 additions
and
4 deletions
common/lib/xmodule/xmodule/open_ended_image_submission.py
+
3
−
3
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
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/openendedchild.py
+
22
−
1
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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment