mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
use ayon api implementation of mime type
This commit is contained in:
parent
2393c33319
commit
61011ecea0
1 changed files with 12 additions and 0 deletions
|
|
@ -1519,12 +1519,24 @@ def get_media_mime_type(filepath: str) -> Optional[str]:
|
|||
Optional[str]: Mime type or None if is unknown mime type.
|
||||
|
||||
"""
|
||||
try:
|
||||
from ayon_api.utils import (
|
||||
get_media_mime_type_for_content as _ayon_api_func
|
||||
)
|
||||
except ImportError:
|
||||
_ayon_api_func = None
|
||||
|
||||
if not filepath or not os.path.exists(filepath):
|
||||
return None
|
||||
|
||||
with open(filepath, "rb") as stream:
|
||||
content = stream.read()
|
||||
|
||||
if _ayon_api_func is not None:
|
||||
mime_type = _ayon_api_func(content)
|
||||
if mime_type is not None:
|
||||
return mime_type
|
||||
|
||||
content_len = len(content)
|
||||
# Pre-validation (largest definition check)
|
||||
# - hopefully there cannot be media defined in less than 12 bytes
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue