From 6503053cd1888a0c27ff6dd6ea794a218947dbf4 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 5 Dec 2025 10:17:30 +0800 Subject: [PATCH] fix: handle file name for uploaded files starting with http MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1064094 --user=刘瑞斌 【工作流知识库】本地文件导入的文档,文档名称显示错误,都显示成file.txt https://www.tapd.cn/62980211/s/1806074 --- .../document_split_node/impl/base_document_split_node.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/application/flow/step_node/document_split_node/impl/base_document_split_node.py b/apps/application/flow/step_node/document_split_node/impl/base_document_split_node.py index 00cf2a483..97244bb61 100644 --- a/apps/application/flow/step_node/document_split_node/impl/base_document_split_node.py +++ b/apps/application/flow/step_node/document_split_node/impl/base_document_split_node.py @@ -12,6 +12,8 @@ from knowledge.serializers.document import default_split_handle, FileBufferHandl def bytes_to_uploaded_file(file_bytes, file_name="file.txt"): + if file_name.startswith("http"): + file_name = "file.txt" content_type, _ = mimetypes.guess_type(file_name) if content_type is None: # 如果未能识别,设置为默认的二进制文件类型 @@ -64,7 +66,7 @@ class BaseDocumentSplitNode(IDocumentSplitNode): for doc in file_list: get_buffer = FileBufferHandle().get_buffer - file_mem = bytes_to_uploaded_file(doc['content'].encode('utf-8')) + file_mem = bytes_to_uploaded_file(doc['content'].encode('utf-8'), doc['name']) if split_strategy == 'qa': result = md_qa_split_handle.handle(file_mem, get_buffer, self._save_image) else: