mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-04-23 10:18:18 +00:00
PR有问题修复
This commit is contained in:
parent
65c466a132
commit
fd657a478a
@ -71,27 +71,25 @@ public class TikaDocumentParser {
|
|||||||
|
|
||||||
public Document parse(File file) {
|
public Document parse(File file) {
|
||||||
AssertUtils.assertNotEmpty("请选择文件", file);
|
AssertUtils.assertNotEmpty("请选择文件", file);
|
||||||
try {
|
// 使用 Tika 自动检测 MIME 类型
|
||||||
|
String fileName = file.getName().toLowerCase();
|
||||||
|
//后缀
|
||||||
|
String ext = FilenameUtils.getExtension(fileName);
|
||||||
|
if (fileName.endsWith(".txt")
|
||||||
|
|| fileName.endsWith(".md")
|
||||||
|
|| fileName.endsWith(".pdf")) {
|
||||||
// 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错)
|
// 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错)
|
||||||
try (InputStream isForParsing = new FileInputStream(file)) {
|
try (InputStream isForParsing = new FileInputStream(file)) {
|
||||||
// 使用 Tika 自动检测 MIME 类型
|
return extractByTika(isForParsing);
|
||||||
String fileName = file.getName().toLowerCase();
|
} catch (IOException e) {
|
||||||
//后缀
|
|
||||||
String ext = FilenameUtils.getExtension(fileName);
|
|
||||||
if (fileName.endsWith(".txt")
|
|
||||||
|| fileName.endsWith(".md")
|
|
||||||
|| fileName.endsWith(".pdf")) {
|
|
||||||
return extractByTika(isForParsing);
|
|
||||||
//update-begin---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
|
|
||||||
} else if (FILE_SUFFIX.contains(ext.toLowerCase())) {
|
|
||||||
return parseDocExcelPdfUsingApachePoi(file);
|
|
||||||
//update-end---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("不支持的文件格式: " + FilenameUtils.getExtension(fileName));
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
//update-begin---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
|
||||||
|
} else if (FILE_SUFFIX.contains(ext.toLowerCase())) {
|
||||||
|
return parseDocExcelPdfUsingApachePoi(file);
|
||||||
|
//update-end---author:wangshuai---date:2026-01-09---for:【QQYUN-14261】【AI】AI助手,支持多模态能力- 文档---
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("不支持的文件格式: " + FilenameUtils.getExtension(fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user