删除上传的临时文件

This commit is contained in:
chenxudong 2025-02-18 11:49:15 +08:00
parent 3d562bdc5a
commit c3d570a3f3
3 changed files with 6 additions and 3 deletions

View File

@ -82,8 +82,7 @@ public class CommonService {
@PostConstruct
public void init() {
String osName = System.getProperty("os.name").toLowerCase();
eleDataPath = osName.startsWith("win") ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
eleDataPath = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
}
/**

View File

@ -12,7 +12,6 @@ public class ExcelParse extends FileParse {
@Override
public String parseAllText(InputStream stream, String fileType) {
String fileTmpPath = createFileTmpPath(fileType);
String res = "";
try {
FileUtil.writeFromStream(stream, fileTmpPath);
if (fileType.endsWith("xlsx")) {
@ -21,7 +20,10 @@ public class ExcelParse extends FileParse {
return OfficeFileUtil.parseXlsAllText(fileTmpPath);
} catch (Exception e) {
log.error("解析{}格式的excel错误具体为{}",fileType, e.getMessage(), e);
} finally {
FileUtil.del(fileTmpPath);
}
return "";
}
}

View File

@ -18,6 +18,8 @@ public class PptParse extends FileParse {
res = fileType.endsWith("pptx") ? OfficeFileUtil.parsePptxAllText(fileTmpPath) : OfficeFileUtil.parsePptAllText(fileTmpPath);
} catch (Exception e) {
log.error("解析{}格式的ppt错误具体为{}",fileType, e.getMessage(), e);
} finally {
FileUtil.del(fileTmpPath);
}
return res;
}