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
7d7eee7d
Commit
7d7eee7d
authored
May 08, 2013
by
Chris Dodge
Committed by
David Baumgold
Jul 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inital work to use streams/chunks when handling uploaded assets
parent
18861e4e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
common/lib/xmodule/xmodule/contentstore/content.py
+4
-1
common/lib/xmodule/xmodule/contentstore/mongo.py
+4
-1
No files found.
common/lib/xmodule/xmodule/contentstore/content.py
View file @
7d7eee7d
...
@@ -113,7 +113,7 @@ class ContentStore(object):
...
@@ -113,7 +113,7 @@ class ContentStore(object):
'''
'''
raise
NotImplementedError
raise
NotImplementedError
def
generate_thumbnail
(
self
,
content
):
def
generate_thumbnail
(
self
,
content
,
tempfile_path
=
None
):
thumbnail_content
=
None
thumbnail_content
=
None
# use a naming convention to associate originals with the thumbnail
# use a naming convention to associate originals with the thumbnail
thumbnail_name
=
StaticContent
.
generate_thumbnail_name
(
content
.
location
.
name
)
thumbnail_name
=
StaticContent
.
generate_thumbnail_name
(
content
.
location
.
name
)
...
@@ -129,7 +129,10 @@ class ContentStore(object):
...
@@ -129,7 +129,10 @@ class ContentStore(object):
# My understanding is that PIL will maintain aspect ratios while restricting
# My understanding is that PIL will maintain aspect ratios while restricting
# the max-height/width to be whatever you pass in as 'size'
# the max-height/width to be whatever you pass in as 'size'
# @todo: move the thumbnail size to a configuration setting?!?
# @todo: move the thumbnail size to a configuration setting?!?
if
tempfile_path
is
None
:
im
=
Image
.
open
(
StringIO
.
StringIO
(
content
.
data
))
im
=
Image
.
open
(
StringIO
.
StringIO
(
content
.
data
))
else
:
im
=
Image
.
open
(
tempfile_path
)
# I've seen some exceptions from the PIL library when trying to save palletted
# I've seen some exceptions from the PIL library when trying to save palletted
# PNG files to JPEG. Per the google-universe, they suggest converting to RGB first.
# PNG files to JPEG. Per the google-universe, they suggest converting to RGB first.
...
...
common/lib/xmodule/xmodule/contentstore/mongo.py
View file @
7d7eee7d
...
@@ -35,7 +35,10 @@ class MongoContentStore(ContentStore):
...
@@ -35,7 +35,10 @@ class MongoContentStore(ContentStore):
with
self
.
fs
.
new_file
(
_id
=
id
,
filename
=
content
.
get_url_path
(),
content_type
=
content
.
content_type
,
with
self
.
fs
.
new_file
(
_id
=
id
,
filename
=
content
.
get_url_path
(),
content_type
=
content
.
content_type
,
displayname
=
content
.
name
,
thumbnail_location
=
content
.
thumbnail_location
,
displayname
=
content
.
name
,
thumbnail_location
=
content
.
thumbnail_location
,
import_path
=
content
.
import_path
)
as
fp
:
import_path
=
content
.
import_path
)
as
fp
:
if
hasattr
(
content
.
data
,
'__iter__'
):
for
chunk
in
content
.
data
:
fp
.
write
(
chunk
)
else
:
fp
.
write
(
content
.
data
)
fp
.
write
(
content
.
data
)
return
content
return
content
...
...
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