mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
fix: handle file name for uploaded files starting with http
--bug=1064094 --user=刘瑞斌 【工作流知识库】本地文件导入的文档,文档名称显示错误,都显示成file.txt https://www.tapd.cn/62980211/s/1806074
This commit is contained in:
parent
7aa13a4206
commit
6503053cd1
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue