Skip to content

Commit

Permalink
Switch to BytesIO for teacher bio photos
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty committed Jan 24, 2025
1 parent 1327348 commit 9a3833d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions esp/esp/web/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ def clean(self, file, initial=None):
file = super(forms.ImageField, self).clean(file, initial)
if file and self.size is not None:
from PIL import Image
from io import StringIO
from io import BytesIO

filename = file.name

picturefile = StringIO()
picturefile = BytesIO()
if hasattr(file, 'temporary_file_path'):
file = file.temporary_file_path()
# Check that there was indeed something submitted. Otherwise give up.
elif hasattr(file, 'read'):
file = StringIO(file.read())
file = BytesIO(file.read())
else:
raise forms.ValidationError('Image unreadable.')

Expand Down

0 comments on commit 9a3833d

Please sign in to comment.