fix: 修复上传文档中后缀为PDF 不识别
This commit is contained in:
parent
3dfcb0ff9a
commit
a9443a638c
@ -149,6 +149,7 @@ class DocSplitHandle(BaseSplitHandle):
|
||||
|
||||
def support(self, file, get_buffer):
|
||||
file_name: str = file.name.lower()
|
||||
if file_name.endswith(".docx") or file_name.endswith(".doc"):
|
||||
if file_name.endswith(".docx") or file_name.endswith(".doc") or file_name.endswith(
|
||||
".DOC") or file_name.endswith(".DOCX"):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -38,7 +38,7 @@ def get_encoding(buffer):
|
||||
class HTMLSplitHandle(BaseSplitHandle):
|
||||
def support(self, file, get_buffer):
|
||||
file_name: str = file.name.lower()
|
||||
if file_name.endswith(".html"):
|
||||
if file_name.endswith(".html") or file_name.endswith(".HTML"):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@ -74,7 +74,8 @@ class PdfSplitHandle(BaseSplitHandle):
|
||||
|
||||
elapsed_time = time.time() - start_time
|
||||
# todo 实现进度条代替下面的普通输出
|
||||
max_kb.debug(f"File: {file.name}, Page: {page_num + 1}, Time : {elapsed_time: .3f}s, content-length: {len(page_content)}")
|
||||
max_kb.debug(
|
||||
f"File: {file.name}, Page: {page_num + 1}, Time : {elapsed_time: .3f}s, content-length: {len(page_content)}")
|
||||
if pattern_list is not None and len(pattern_list) > 0:
|
||||
split_model = SplitModel(pattern_list, with_filter, limit)
|
||||
else:
|
||||
@ -96,6 +97,6 @@ class PdfSplitHandle(BaseSplitHandle):
|
||||
|
||||
def support(self, file, get_buffer):
|
||||
file_name: str = file.name.lower()
|
||||
if file_name.endswith(".pdf"):
|
||||
if file_name.endswith(".pdf") or file_name.endswith(".PDF"):
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -26,7 +26,8 @@ class TextSplitHandle(BaseSplitHandle):
|
||||
def support(self, file, get_buffer):
|
||||
buffer = get_buffer(file)
|
||||
file_name: str = file.name.lower()
|
||||
if file_name.endswith(".md") or file_name.endswith('.txt'):
|
||||
if file_name.endswith(".md") or file_name.endswith('.txt') or file_name.endswith('.TXT') or file_name.endswith(
|
||||
'.MD'):
|
||||
return True
|
||||
result = detect(buffer)
|
||||
if result['encoding'] is not None and result['confidence'] is not None and result['encoding'] != 'ascii' and \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user