Skip to content

Commit 6503053

Browse files
committed
fix: handle file name for uploaded files starting with http
--bug=1064094 --user=刘瑞斌 【工作流知识库】本地文件导入的文档,文档名称显示错误,都显示成file.txt https://www.tapd.cn/62980211/s/1806074
1 parent 7aa13a4 commit 6503053

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/application/flow/step_node/document_split_node/impl/base_document_split_node.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313

1414
def bytes_to_uploaded_file(file_bytes, file_name="file.txt"):
15+
if file_name.startswith("http"):
16+
file_name = "file.txt"
1517
content_type, _ = mimetypes.guess_type(file_name)
1618
if content_type is None:
1719
# 如果未能识别,设置为默认的二进制文件类型
@@ -64,7 +66,7 @@ def execute(self, document_list, knowledge_id, split_strategy, paragraph_title_r
6466
for doc in file_list:
6567
get_buffer = FileBufferHandle().get_buffer
6668

67-
file_mem = bytes_to_uploaded_file(doc['content'].encode('utf-8'))
69+
file_mem = bytes_to_uploaded_file(doc['content'].encode('utf-8'), doc['name'])
6870
if split_strategy == 'qa':
6971
result = md_qa_split_handle.handle(file_mem, get_buffer, self._save_image)
7072
else:

0 commit comments

Comments
 (0)