Merge pull request #105 from WonderfulLife/fix-zero-bytes-remaining

Reset image stream position after using `.tell()`
This commit is contained in:
Pouria Hadjibagheri 2018-02-24 01:25:56 +00:00 committed by GitHub
commit af8f17e141
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,5 +1,5 @@
# Python internal library.
from os import path, SEEK_END
from os import path, SEEK_END, SEEK_SET
from uuid import uuid4
from collections import namedtuple
@ -63,6 +63,7 @@ class ImageForm(forms.Form):
# may be stored as uploaded.
image = self._process_raster(image, image_extension)
image_size = image.tell()
image.seek(0, SEEK_SET)
# Processed file (or the actual file in the case of SVG) is now
# saved in the memory as a Django object.