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
4d1f9d2e
Commit
4d1f9d2e
authored
Jan 29, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Function to upload stuff to S3
parent
929160e1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
common/lib/xmodule/xmodule/open_ended_image_submission.py
+21
-0
No files found.
common/lib/xmodule/xmodule/open_ended_image_submission.py
View file @
4d1f9d2e
...
...
@@ -82,6 +82,27 @@ def run_image_tests(image):
image_properties
=
ImageProperties
(
image
)
return
image_properties
.
run_tests
()
def
upload_to_s3
(
string_to_upload
,
keyname
):
'''
Upload file to S3 using provided keyname.
Returns:
public_url: URL to access uploaded file
'''
try
:
conn
=
S3Connection
(
settings
.
AWS_ACCESS_KEY_ID
,
settings
.
AWS_SECRET_ACCESS_KEY
)
bucketname
=
str
(
AWS_STORAGE_BUCKET_NAME
)
bucket
=
conn
.
create_bucket
(
bucketname
.
lower
())
k
=
Key
(
bucket
)
k
.
key
=
keyname
k
.
set_contents_from_string
(
string_to_upload
)
public_url
=
k
.
generate_url
(
60
*
60
*
24
*
365
)
# URL timeout in seconds.
return
True
,
public_url
except
:
return
False
,
"Could not connect 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