mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 01:29:16 +02:00
Fixed #73: broken file upload
This commit is contained in:
parent
8283a73a7f
commit
8c7e943013
4 changed files with 32 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
import magic
|
||||
import mimetypes
|
||||
import re
|
||||
|
||||
from django.db.models import Q
|
||||
|
@ -42,7 +43,13 @@ def get_query(query_string, search_fields):
|
|||
|
||||
def guess_mimetype(f):
|
||||
b = min(100000, f.size)
|
||||
return magic.from_buffer(f.read(b), mime=True)
|
||||
t = magic.from_buffer(f.read(b), mime=True)
|
||||
if t == 'application/octet-stream':
|
||||
# failure, we try guessing by extension
|
||||
mt, _ = mimetypes.guess_type(f.path)
|
||||
if mt:
|
||||
t = mt
|
||||
return t
|
||||
|
||||
|
||||
def compute_status(jobs):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue