##// END OF EJS Templates
Try all chunks when detecting file mimetype
neko259 -
r1869:f74167a6 default
parent child Browse files
Show More
@@ -30,6 +30,7 b' FILE_TYPES_AUDIO = ('
30 'audio/mp3',
30 'audio/mp3',
31 'audio/opus',
31 'audio/opus',
32 'audio/x-flac',
32 'audio/x-flac',
33 'audio/mpeg',
33 )
34 )
34 FILE_TYPES_IMAGE = (
35 FILE_TYPES_IMAGE = (
35 'image/jpeg',
36 'image/jpeg',
@@ -135,7 +135,7 b' def get_upload_filename(model_instance, '
135
135
136
136
137 def get_file_mimetype(file) -> str:
137 def get_file_mimetype(file) -> str:
138 file_type = magic.from_buffer(file.chunks().__next__(), mime=True)
138 file_type = magic.from_file(settings.MEDIA_ROOT + file.name, mime=True)
139 if file_type is None:
139 if file_type is None:
140 file_type = 'application/octet-stream'
140 file_type = 'application/octet-stream'
141 elif type(file_type) == bytes:
141 elif type(file_type) == bytes:
General Comments 0
You need to be logged in to leave comments. Login now