记得上下班打卡 | git大法好,push需谨慎

Commit dfc5de1d authored by jiangxiulong's avatar jiangxiulong

二次上传未删除临时图片

parent f493b25d
package com.liquidnet.commons.lang.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
......@@ -11,6 +12,7 @@ import java.security.MessageDigest;
* @author jiangxiulong
* @since 2021-06-10
*/
@Slf4j
public class FilesUtils {
/**
* MultipartFile 转 File
......@@ -45,7 +47,7 @@ public class FilesUtils {
os.close();
ins.close();
} catch (Exception e) {
e.printStackTrace();
log.error("inputStreamToFileError", e);
}
}
......@@ -54,9 +56,13 @@ public class FilesUtils {
* @param file
*/
public static void delteTempFile(File file) {
try {
if (file != null) {
file.delete();
}
} catch (Exception e) {
log.error("delteTempFileError", e);
}
}
/**
......@@ -81,13 +87,13 @@ public class FilesUtils {
BigInteger bigInt = new BigInteger(1, digest.digest());
return bigInt.toString(16);
} catch (Exception e) {
e.printStackTrace();
log.error("getFileMD5CatchError", e);
return null;
} finally {
try {
in.close();
} catch (Exception e) {
e.printStackTrace();
log.error("getFileMD5FinallyError", e);
}
}
}
......
......@@ -111,7 +111,6 @@ public class AlOssController {
}
ossClient.shutdown();
FilesUtils.delteTempFile(fileNew); // 删除临时文件
// 入库
PlatformOssFiles platformOssFilesDate = new PlatformOssFiles();
......@@ -131,6 +130,9 @@ public class AlOssController {
PlatformOssFiles platformOssFilesOne = platformOssFiles.get(0);
BeanUtils.copyProperties(platformOssFilesOne, uploadVo);
}
FilesUtils.delteTempFile(fileNew); // 删除临时文件
return ResponseDto.success(uploadVo);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment