fix: Resolve issue with plain text files not having magic file info

This commit is contained in:
Igor Ilic 2025-10-19 23:10:53 +02:00
parent 6bc9b1d482
commit f88277c467

View file

@ -124,6 +124,12 @@ def guess_file_type(file: BinaryIO) -> filetype.Type:
"""
file_type = filetype.guess(file)
# If file type could not be determined consider it a plain text file as they don't have magic number encoding
if file_type is None:
from filetype.types.base import Type
file_type = Type("text/plain", "txt")
if file_type is None:
raise FileTypeException(f"Unknown file detected: {file.name}.")