Add: function to retrieve MIME type of a file
This commit is contained in:
parent
876c4dba03
commit
265e228a84
1 changed files with 17 additions and 0 deletions
17
archivist/utils/files.py
Normal file
17
archivist/utils/files.py
Normal file
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in a new issue