Skip to content

Commit

Permalink
Merge pull request #589 from safaariman/master
Browse files Browse the repository at this point in the history
Fix upload issue of SVG thumbnails to S3 storage #587
  • Loading branch information
jrief authored Dec 26, 2021
2 parents 510d8a6 + 26d5571 commit 92060b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions easy_thumbnails/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def generate_thumbnail(self, thumbnail_options, silent_template_exception=False)
subsampling=subsampling)
data = img.read()

# S3 requires the data as bytes.
if not isinstance(data, bytes):
data = data.encode()

thumbnail = ThumbnailFile(
filename, file=ContentFile(data), storage=self.thumbnail_storage,
thumbnail_options=thumbnail_options)
Expand Down
5 changes: 3 additions & 2 deletions easy_thumbnails/source_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def vil_image(source, **options):

if not source:
return
filename = source.source_storage.path(source.file.name)
# path method should not be implemented for remote storages. We can pass the file directly.
# filename = source.source_storage.path(source.file.name)
try:
return Image.load(filename)
return Image.load(source.file)
except Exception as exc:
raise exc

0 comments on commit 92060b9

Please sign in to comment.