Skip to content

Commit fd657a4

Browse files
committed
PR有问题修复
1 parent 65c466a commit fd657a4

File tree

1 file changed

+15
-17
lines changed
  • jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document

1 file changed

+15
-17
lines changed

jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,25 @@ public TikaDocumentParser(Supplier<Parser> parserSupplier, Supplier<ContentHandl
7171

7272
public Document parse(File file) {
7373
AssertUtils.assertNotEmpty("请选择文件", file);
74-
try {
74+
// 使用 Tika 自动检测 MIME 类型
75+
String fileName = file.getName().toLowerCase();
76+
//后缀
77+
String ext = FilenameUtils.getExtension(fileName);
78+
if (fileName.endsWith(".txt")
79+
|| fileName.endsWith(".md")
80+
|| fileName.endsWith(".pdf")) {
7581
// 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错)
7682
try (InputStream isForParsing = new FileInputStream(file)) {
77-
// 使用 Tika 自动检测 MIME 类型
78-
String fileName = file.getName().toLowerCase();
79-
//后缀
80-
String ext = FilenameUtils.getExtension(fileName);
81-
if (fileName.endsWith(".txt")
82-
|| fileName.endsWith(".md")
83-
|| fileName.endsWith(".pdf")) {
84-
return extractByTika(isForParsing);
85-
//update-begin---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
86-
} else if (FILE_SUFFIX.contains(ext.toLowerCase())) {
87-
return parseDocExcelPdfUsingApachePoi(file);
88-
//update-end---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
89-
} else {
90-
throw new IllegalArgumentException("不支持的文件格式: " + FilenameUtils.getExtension(fileName));
91-
}
92-
} catch (IOException e) {
83+
return extractByTika(isForParsing);
84+
} catch (IOException e) {
9385
throw new RuntimeException(e);
9486
}
87+
//update-begin---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
88+
} else if (FILE_SUFFIX.contains(ext.toLowerCase())) {
89+
return parseDocExcelPdfUsingApachePoi(file);
90+
//update-end---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
91+
} else {
92+
throw new IllegalArgumentException("不支持的文件格式: " + FilenameUtils.getExtension(fileName));
9593
}
9694
}
9795

0 commit comments

Comments
 (0)