mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 03:35:51 +08:00
fix(tool_file_manager): raise ValueError when get timeout (#11928)
Signed-off-by: -LAN- <laipz8200@outlook.com>
This commit is contained in:
parent
c07d9e96ce
commit
90323cd355
@ -8,9 +8,10 @@ from mimetypes import guess_extension, guess_type
|
|||||||
from typing import Optional, Union
|
from typing import Optional, Union
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from httpx import get
|
import httpx
|
||||||
|
|
||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
|
from core.helper import ssrf_proxy
|
||||||
from extensions.ext_database import db
|
from extensions.ext_database import db
|
||||||
from extensions.ext_storage import storage
|
from extensions.ext_storage import storage
|
||||||
from models.model import MessageFile
|
from models.model import MessageFile
|
||||||
@ -94,12 +95,11 @@ class ToolFileManager:
|
|||||||
) -> ToolFile:
|
) -> ToolFile:
|
||||||
# try to download image
|
# try to download image
|
||||||
try:
|
try:
|
||||||
response = get(file_url)
|
response = ssrf_proxy.get(file_url)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
blob = response.content
|
blob = response.content
|
||||||
except Exception as e:
|
except httpx.TimeoutException as e:
|
||||||
logger.exception(f"Failed to download file from {file_url}")
|
raise ValueError(f"timeout when downloading file from {file_url}")
|
||||||
raise
|
|
||||||
|
|
||||||
mimetype = guess_type(file_url)[0] or "octet/stream"
|
mimetype = guess_type(file_url)[0] or "octet/stream"
|
||||||
extension = guess_extension(mimetype) or ".bin"
|
extension = guess_extension(mimetype) or ".bin"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user