Skip to content

Commit c615aca

Browse files
authored
improve determination accuracy (#18)
1 parent cd18bc8 commit c615aca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

safe_s3_storage/file_validator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class FileValidator:
4949

5050
def _validate_mime_type(self, *, file_name: str, file_content: bytes) -> str:
5151
mime_type_prediction: typing.Final = Magika().identify_bytes(file_content)
52-
mime_type: typing.Final = mime_type_prediction.prediction.dl.mime_type
52+
if mime_type_prediction.dl.extensions:
53+
mime_type = mime_type_prediction.dl.mime_type
54+
else:
55+
mime_type = mime_type_prediction.output.mime_type
5356
if self.allowed_mime_types is None or mime_type in self.allowed_mime_types:
5457
return mime_type
5558

0 commit comments

Comments
 (0)