mirror of
https://github.com/jazzband/django-avatar.git
synced 2026-03-16 22:20:30 +00:00
Py3 fix
This commit is contained in:
parent
d3da18d1d2
commit
fc3dc002da
1 changed files with 3 additions and 2 deletions
|
|
@ -39,7 +39,7 @@ class UploadAvatarForm(forms.Form):
|
|||
"limitation")
|
||||
|
||||
# Construct 256 bytes needed for mime validation
|
||||
magic_buffer = ""
|
||||
magic_buffer = six.b('')
|
||||
for chunk in data.chunks():
|
||||
magic_buffer += chunk
|
||||
if len(magic_buffer) >= 256:
|
||||
|
|
@ -47,7 +47,8 @@ class UploadAvatarForm(forms.Form):
|
|||
|
||||
# https://github.com/ahupp/python-magic#usage
|
||||
mime = magic.from_buffer(magic_buffer, mime=True)
|
||||
|
||||
if six.PY3:
|
||||
mime = mime.decode('utf-8')
|
||||
if mime not in settings.AVATAR_ALLOWED_MIMETYPES:
|
||||
err = _(
|
||||
"File content is invalid. Detected: %(mimetype)s "
|
||||
|
|
|
|||
Loading…
Reference in a new issue