|
|
@@ -1,3 +1,5 @@
|
|
|
+from pathlib import Path
|
|
|
+
|
|
|
from magika import Magika
|
|
|
|
|
|
|
|
|
@@ -16,5 +18,9 @@ def guess_suffix_by_bytes(file_bytes) -> str:
|
|
|
|
|
|
|
|
|
def guess_suffix_by_path(file_path) -> str:
|
|
|
+ if not isinstance(file_path, Path):
|
|
|
+ file_path = Path(file_path)
|
|
|
suffix = magika.identify_path(file_path).prediction.output.label
|
|
|
+ if suffix in ["ai"] and file_path.suffix in [".pdf"]:
|
|
|
+ suffix = "pdf"
|
|
|
return suffix
|