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

Commit dfc5de1d authored by jiangxiulong's avatar jiangxiulong

二次上传未删除临时图片

parent f493b25d
package com.liquidnet.commons.lang.util; package com.liquidnet.commons.lang.util;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
...@@ -11,6 +12,7 @@ import java.security.MessageDigest; ...@@ -11,6 +12,7 @@ import java.security.MessageDigest;
* @author jiangxiulong * @author jiangxiulong
* @since 2021-06-10 * @since 2021-06-10
*/ */
@Slf4j
public class FilesUtils { public class FilesUtils {
/** /**
* MultipartFile 转 File * MultipartFile 转 File
...@@ -45,7 +47,7 @@ public class FilesUtils { ...@@ -45,7 +47,7 @@ public class FilesUtils {
os.close(); os.close();
ins.close(); ins.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("inputStreamToFileError", e);
} }
} }
...@@ -54,9 +56,13 @@ public class FilesUtils { ...@@ -54,9 +56,13 @@ public class FilesUtils {
* @param file * @param file
*/ */
public static void delteTempFile(File file) { public static void delteTempFile(File file) {
try {
if (file != null) { if (file != null) {
file.delete(); file.delete();
} }
} catch (Exception e) {
log.error("delteTempFileError", e);
}
} }
/** /**
...@@ -81,13 +87,13 @@ public class FilesUtils { ...@@ -81,13 +87,13 @@ public class FilesUtils {
BigInteger bigInt = new BigInteger(1, digest.digest()); BigInteger bigInt = new BigInteger(1, digest.digest());
return bigInt.toString(16); return bigInt.toString(16);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("getFileMD5CatchError", e);
return null; return null;
} finally { } finally {
try { try {
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("getFileMD5FinallyError", e);
} }
} }
} }
......
...@@ -111,7 +111,6 @@ public class AlOssController { ...@@ -111,7 +111,6 @@ public class AlOssController {
} }
ossClient.shutdown(); ossClient.shutdown();
FilesUtils.delteTempFile(fileNew); // 删除临时文件
// 入库 // 入库
PlatformOssFiles platformOssFilesDate = new PlatformOssFiles(); PlatformOssFiles platformOssFilesDate = new PlatformOssFiles();
...@@ -131,6 +130,9 @@ public class AlOssController { ...@@ -131,6 +130,9 @@ public class AlOssController {
PlatformOssFiles platformOssFilesOne = platformOssFiles.get(0); PlatformOssFiles platformOssFilesOne = platformOssFiles.get(0);
BeanUtils.copyProperties(platformOssFilesOne, uploadVo); BeanUtils.copyProperties(platformOssFilesOne, uploadVo);
} }
FilesUtils.delteTempFile(fileNew); // 删除临时文件
return ResponseDto.success(uploadVo); 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