fix: http node download file always image type (#11319)
This commit is contained in:
parent
98a1b01b0c
commit
d470e55f8c
@ -1,11 +1,9 @@
|
|||||||
import logging
|
import logging
|
||||||
from collections.abc import Mapping, Sequence
|
from collections.abc import Mapping, Sequence
|
||||||
from mimetypes import guess_extension
|
|
||||||
from os import path
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from configs import dify_config
|
from configs import dify_config
|
||||||
from core.file import File, FileTransferMethod, FileType
|
from core.file import File, FileTransferMethod
|
||||||
from core.tools.tool_file_manager import ToolFileManager
|
from core.tools.tool_file_manager import ToolFileManager
|
||||||
from core.workflow.entities.node_entities import NodeRunResult
|
from core.workflow.entities.node_entities import NodeRunResult
|
||||||
from core.workflow.entities.variable_entities import VariableSelector
|
from core.workflow.entities.variable_entities import VariableSelector
|
||||||
@ -150,11 +148,6 @@ class HttpRequestNode(BaseNode[HttpRequestNodeData]):
|
|||||||
content = response.content
|
content = response.content
|
||||||
|
|
||||||
if is_file and content_type:
|
if is_file and content_type:
|
||||||
# extract filename from url
|
|
||||||
filename = path.basename(url)
|
|
||||||
# extract extension if possible
|
|
||||||
extension = guess_extension(content_type) or ".bin"
|
|
||||||
|
|
||||||
tool_file = ToolFileManager.create_file_by_raw(
|
tool_file = ToolFileManager.create_file_by_raw(
|
||||||
user_id=self.user_id,
|
user_id=self.user_id,
|
||||||
tenant_id=self.tenant_id,
|
tenant_id=self.tenant_id,
|
||||||
@ -165,7 +158,6 @@ class HttpRequestNode(BaseNode[HttpRequestNodeData]):
|
|||||||
|
|
||||||
mapping = {
|
mapping = {
|
||||||
"tool_file_id": tool_file.id,
|
"tool_file_id": tool_file.id,
|
||||||
"type": FileType.IMAGE.value,
|
|
||||||
"transfer_method": FileTransferMethod.TOOL_FILE.value,
|
"transfer_method": FileTransferMethod.TOOL_FILE.value,
|
||||||
}
|
}
|
||||||
file = file_factory.build_from_mapping(
|
file = file_factory.build_from_mapping(
|
||||||
|
Loading…
Reference in New Issue
Block a user