diff --git a/src/pretix/control/forms/__init__.py b/src/pretix/control/forms/__init__.py index 752b3a9182..01d673db12 100644 --- a/src/pretix/control/forms/__init__.py +++ b/src/pretix/control/forms/__init__.py @@ -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 diff --git a/src/pretix/helpers/images.py b/src/pretix/helpers/images.py index 728413c624..31773849f6 100644 --- a/src/pretix/helpers/images.py +++ b/src/pretix/helpers/images.py @@ -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: