Selaa lähdekoodia

enhance guessing mimetype of tool file (#17640)

tags/1.3.0
Qun 6 kuukautta sitten
vanhempi
commit
0e136b42a2
No account linked to committer's email address
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5
    1
      api/core/tools/tool_file_manager.py

+ 5
- 1
api/core/tools/tool_file_manager.py Näytä tiedosto

@@ -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}"

Loading…
Peruuta
Tallenna