Fixed #1378 - Before validating an in-memory image file, seek to the beginning of the file. This is required to in case the same file is validated more than once. Currently, the same image file is validated twice when uploading an ImageField through the browser API - once when creating the model object, and once when rendering the HTML response.

This commit is contained in:
danra 2014-07-03 01:57:15 +03:00
parent 91eabd54bb
commit e77320fa5b

View File

@ -1004,7 +1004,8 @@ class ImageField(FileField):
if hasattr(data, 'temporary_file_path'):
file = data.temporary_file_path()
else:
if hasattr(data, 'read'):
if hasattr(data, 'read') and hasattr(data, 'seek'):
data.seek(0)
file = BytesIO(data.read())
else:
file = BytesIO(data['content'])