From 62395dc62dfcc350e89cb5b814c356c47bf28373 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Fri, 24 Jan 2025 23:42:39 +0100 Subject: [PATCH] Add util for getting mime types --- backend/utils/__init__.py | 0 backend/utils/files.py | 15 +++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 backend/utils/__init__.py create mode 100644 backend/utils/files.py diff --git a/backend/utils/__init__.py b/backend/utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/utils/files.py b/backend/utils/files.py new file mode 100644 index 0000000..1dd2519 --- /dev/null +++ b/backend/utils/files.py @@ -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