# HG changeset patch # User neko259 # Date 2017-02-27 10:51:50 # Node ID f74167a64588b536647ab8fd1e5a0b11c1c94cd8 # Parent 982690bdecbdccf2b5fa722c2e39a6f5287c692e Try all chunks when detecting file mimetype diff --git a/boards/models/attachment/viewers.py b/boards/models/attachment/viewers.py --- a/boards/models/attachment/viewers.py +++ b/boards/models/attachment/viewers.py @@ -30,6 +30,7 @@ FILE_TYPES_AUDIO = ( 'audio/mp3', 'audio/opus', 'audio/x-flac', + 'audio/mpeg', ) FILE_TYPES_IMAGE = ( 'image/jpeg', diff --git a/boards/utils.py b/boards/utils.py --- a/boards/utils.py +++ b/boards/utils.py @@ -135,7 +135,7 @@ def get_upload_filename(model_instance, def get_file_mimetype(file) -> str: - file_type = magic.from_buffer(file.chunks().__next__(), mime=True) + file_type = magic.from_file(settings.MEDIA_ROOT + file.name, mime=True) if file_type is None: file_type = 'application/octet-stream' elif type(file_type) == bytes: