Procházet zdrojové kódy

enhance guessing mimetype of tool file (#17640)

tags/1.3.0
Qun před 6 měsíci
rodič
revize
0e136b42a2
Žádný účet není propojen s e-mailovou adresou tvůrce revize
1 změnil soubory, kde provedl 5 přidání a 1 odebrání
  1. 5
    1
      api/core/tools/tool_file_manager.py

+ 5
- 1
api/core/tools/tool_file_manager.py Zobrazit soubor

@@ -108,7 +108,11 @@ class ToolFileManager:
except httpx.TimeoutException:
raise ValueError(f"timeout when downloading file from {file_url}")

mimetype = guess_type(file_url)[0] or "application/octet-stream"
mimetype = (
guess_type(file_url)[0]
or response.headers.get("Content-Type", "").split(";")[0].strip()
or "application/octet-stream"
)
extension = guess_extension(mimetype) or ".bin"
unique_name = uuid4().hex
filename = f"{unique_name}{extension}"

Načítá se…
Zrušit
Uložit