Add util for getting mime types

This commit is contained in:
Aroy-Art 2025-01-24 23:42:39 +01:00
parent b4b084fcc3
commit 62395dc62d
Signed by: Aroy
GPG key ID: 583642324A1D2070
2 changed files with 15 additions and 0 deletions

View file

15
backend/utils/files.py Normal file
View file

@ -0,0 +1,15 @@
import mimetypes
def get_mime_type(file_path: str) -> str:
"""
Get the MIME type of a file based on the file path.
Parameters:
file_path (str): The path to the file from which to determine the MIME type.
Returns:
str: The MIME type of the file.
"""
mime_type, encoding = mimetypes.guess_type(file_path)
return mime_type