# HG changeset patch # User neko259 # Date 2016-10-30 07:29:25 # Node ID 21e5d408a1a59aec0e3a97cb206d70c8ce34e9b8 # Parent 0fb0af80af576c315233af5abe2ac75a7b84eaba Compatibility with python-magic of latest version (returts str, not bytes) diff --git a/boards/utils.py b/boards/utils.py --- a/boards/utils.py +++ b/boards/utils.py @@ -137,8 +137,9 @@ def get_upload_filename(model_instance, def get_file_mimetype(file) -> str: - type = magic.from_buffer(file.chunks().__next__(), mime=True) - if type is not None: - return type.decode() - else: - return 'application/octet-stream' + file_type = magic.from_buffer(file.chunks().__next__(), mime=True) + if file_type is None: + file_type = 'application/octet-stream' + else if type(file_type) == bytes: + file_type = file_type.decode() + return type