Use unicode strings for content type
authorThierry Florac <thierry.florac@onf.fr>
Tue, 06 Jun 2017 17:30:16 +0200
changeset 35 57b510d3cbe4
parent 34 47dd5b37fab5
child 36 bbe52bba4db9
Use unicode strings for content type
src/pyams_file/file.py
--- a/src/pyams_file/file.py	Sun May 21 01:50:16 2017 +0200
+++ b/src/pyams_file/file.py	Tue Jun 06 17:30:16 2017 +0200
@@ -208,7 +208,7 @@
         if hasattr(magic, 'detect_from_content'):
             result = magic.detect_from_content(input)
             if result:
-                return result.mime_type.encode()
+                return result.mime_type
         elif hasattr(magic, 'from_buffer'):
             return magic.from_buffer(input, mime=True)
     else:
@@ -222,11 +222,11 @@
     content-type recognition
     """
     content_type = get_magic_content_type(data)
-    if content_type.startswith(b'image/'):
+    if content_type.startswith('image/'):
         factory = ImageFile
-    elif content_type.startswith(b'video/'):
+    elif content_type.startswith('video/'):
         factory = VideoFile
-    elif content_type.startswith(b'audio/'):
+    elif content_type.startswith('audio/'):
         factory = AudioFile
     else:
         factory = File