mirror of
https://github.com/tcsenpai/Zundler.git
synced 2025-06-06 11:35:40 +00:00
Guess mime type from filename first
It seems libmagic is too unreliable.
This commit is contained in:
parent
6b9c894ed2
commit
708733c51e
@ -20,6 +20,7 @@ import base64
|
||||
from fnmatch import fnmatch
|
||||
import json
|
||||
import logging
|
||||
import mimetypes
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
@ -138,7 +139,9 @@ def prepare_file(filename):
|
||||
_, ext = os.path.splitext(filename)
|
||||
ext = ext.lower()[1:]
|
||||
data = open(filename, "rb").read()
|
||||
mime_type = mime_type_from_bytes(filename, data)
|
||||
mime_type, _ = mimetypes.guess_type(filename)
|
||||
if not mime_type:
|
||||
mime_type = mime_type_from_bytes(filename, data)
|
||||
base64encoded = False
|
||||
|
||||
if ext == "css":
|
||||
|
Loading…
x
Reference in New Issue
Block a user