From 265e228a8411d88e477310a2616c6a28f31e7a58 Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Thu, 11 Apr 2024 15:54:27 +0200 Subject: [PATCH] Add: function to retrieve MIME type of a file --- archivist/utils/files.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 archivist/utils/files.py diff --git a/archivist/utils/files.py b/archivist/utils/files.py new file mode 100644 index 0000000..20696ef --- /dev/null +++ b/archivist/utils/files.py @@ -0,0 +1,17 @@ +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 + + +