mirror of
https://github.com/pretix/pretix.git
synced 2026-05-03 14:54:04 +00:00
forms: fix image file upload in CachedFileField
This commit is contained in:
committed by
Raphael Michel
parent
c6fa19d771
commit
2d5d27e950
@@ -229,7 +229,7 @@ class ExtValidationMixin:
|
||||
raise forms.ValidationError(_("Filetype not allowed!"))
|
||||
|
||||
if ext in IMAGE_EXTS:
|
||||
validate_uploaded_file_for_valid_image(data)
|
||||
validate_uploaded_file_for_valid_image(data if isinstance(data, UploadedFile) else data.file)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -44,11 +44,12 @@ def validate_uploaded_file_for_valid_image(f):
|
||||
# have to read the data into memory.
|
||||
if hasattr(f, 'temporary_file_path'):
|
||||
file = f.temporary_file_path()
|
||||
elif hasattr(f, 'read'):
|
||||
if hasattr(f, 'seek') and callable(f.seek):
|
||||
f.seek(0)
|
||||
file = BytesIO(f.read())
|
||||
else:
|
||||
if hasattr(f, 'read'):
|
||||
file = BytesIO(f.read())
|
||||
else:
|
||||
file = BytesIO(f['content'])
|
||||
file = BytesIO(f['content'])
|
||||
|
||||
try:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user