0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Fix handling of temporary upload files

This commit is contained in:
Dan Braghis 2022-11-02 08:58:43 +00:00 committed by Matt Westcott
parent 2df8dc73ba
commit e93f322e94

View File

@ -129,10 +129,11 @@ class WagtailImageField(ImageField):
if f is None:
return None
# We need to get a file object for Pillow. We might have a path or we might
# have to read the data into memory.
# We need to get a file object for Pillow. When we get a path, we need to open
# the file first. And we have to read the data into memory to pass to Willow.
if hasattr(data, "temporary_file_path"):
file = data.temporary_file_path()
with open(data.temporary_file_path(), "rb") as fh:
file = BytesIO(fh.read())
else:
if hasattr(data, "read"):
file = BytesIO(data.read())