mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
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:
parent
91eabd54bb
commit
e77320fa5b
|
@ -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'])
|
||||
|
|
Loading…
Reference in New Issue
Block a user