added auto-detection for the output type on the client side to be able to download binary files such as videos
This commit is contained in:
parent
775c78c6cb
commit
1a49aa3779
5 changed files with 39 additions and 1 deletions
|
@ -1 +1,2 @@
|
|||
from . import parameters
|
||||
from . import mimetypes
|
||||
|
|
21
source/utils/mimetypes.py
Normal file
21
source/utils/mimetypes.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
def is_textlike(mimetype: str) -> bool:
|
||||
"""
|
||||
Determinate if a mimetype is considered as holding text
|
||||
:param mimetype: the mimetype to check
|
||||
:return: True if the mimetype represent text, False otherwise
|
||||
"""
|
||||
|
||||
# check the family of the mimetype
|
||||
if mimetype.startswith("text/"):
|
||||
return True
|
||||
|
||||
# check applications formats that are text formatted
|
||||
if mimetype in [
|
||||
"application/xml",
|
||||
"application/json",
|
||||
"application/javascript"
|
||||
]:
|
||||
return True
|
||||
|
||||
# otherwise consider the file as non-text
|
||||
return False
|
Loading…
Add table
Add a link
Reference in a new issue