异常处理

This commit is contained in:
shikong 2024-03-15 11:09:03 +08:00
parent 054ab25205
commit 04cfcfd22a

View File

@ -270,11 +270,17 @@ public class VideoService {
if(ffmpegConfig.getUseTmpFile()) { if(ffmpegConfig.getUseTmpFile()) {
ServletOutputStream servletOutputStream = response.getOutputStream(); ServletOutputStream servletOutputStream = response.getOutputStream();
IoUtil.copy(new FileInputStream(file), servletOutputStream); try{
response.flushBuffer(); log.info("临时文件 {}(大小 {})", file.getAbsolutePath(), file.length());
System.gc(); IoUtil.copy(new FileInputStream(file), servletOutputStream);
boolean delete = file.delete(); response.flushBuffer();
log.info("删除临时文件 {} => {}", file, delete); } catch (Exception e){
log.error("写入 http 响应异常: {}", e.getMessage());
} finally {
System.gc();
boolean delete = file.delete();
log.info("删除临时文件 {} => {}", file, delete);
}
} }
} }