删除上传的临时文件
This commit is contained in:
parent
3d562bdc5a
commit
c3d570a3f3
|
|
@ -82,8 +82,7 @@ public class CommonService {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
String osName = System.getProperty("os.name").toLowerCase();
|
eleDataPath = EleCommonUtil.isWinOs() ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
|
||||||
eleDataPath = osName.startsWith("win") ? environment.getProperty("data.windows.path") : environment.getProperty("data.linux.path");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ public class ExcelParse extends FileParse {
|
||||||
@Override
|
@Override
|
||||||
public String parseAllText(InputStream stream, String fileType) {
|
public String parseAllText(InputStream stream, String fileType) {
|
||||||
String fileTmpPath = createFileTmpPath(fileType);
|
String fileTmpPath = createFileTmpPath(fileType);
|
||||||
String res = "";
|
|
||||||
try {
|
try {
|
||||||
FileUtil.writeFromStream(stream, fileTmpPath);
|
FileUtil.writeFromStream(stream, fileTmpPath);
|
||||||
if (fileType.endsWith("xlsx")) {
|
if (fileType.endsWith("xlsx")) {
|
||||||
|
|
@ -21,7 +20,10 @@ public class ExcelParse extends FileParse {
|
||||||
return OfficeFileUtil.parseXlsAllText(fileTmpPath);
|
return OfficeFileUtil.parseXlsAllText(fileTmpPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("解析{}格式的excel错误,具体为{}",fileType, e.getMessage(), e);
|
log.error("解析{}格式的excel错误,具体为{}",fileType, e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
FileUtil.del(fileTmpPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ public class PptParse extends FileParse {
|
||||||
res = fileType.endsWith("pptx") ? OfficeFileUtil.parsePptxAllText(fileTmpPath) : OfficeFileUtil.parsePptAllText(fileTmpPath);
|
res = fileType.endsWith("pptx") ? OfficeFileUtil.parsePptxAllText(fileTmpPath) : OfficeFileUtil.parsePptAllText(fileTmpPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("解析{}格式的ppt错误,具体为{}",fileType, e.getMessage(), e);
|
log.error("解析{}格式的ppt错误,具体为{}",fileType, e.getMessage(), e);
|
||||||
|
} finally {
|
||||||
|
FileUtil.del(fileTmpPath);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue