From 5d221f7f04586f811d7f78d4527b3428b32a982d Mon Sep 17 00:00:00 2001 From: ronger Date: Mon, 24 Jan 2022 21:50:13 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=89=B9=E9=87=8F=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=20md5=20?= =?UTF-8?q?=E5=80=BC=E8=8E=B7=E5=8F=96=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rymcu/forest/web/api/common/UploadController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/rymcu/forest/web/api/common/UploadController.java b/src/main/java/com/rymcu/forest/web/api/common/UploadController.java index a3ff0a9..788eb28 100644 --- a/src/main/java/com/rymcu/forest/web/api/common/UploadController.java +++ b/src/main/java/com/rymcu/forest/web/api/common/UploadController.java @@ -128,7 +128,7 @@ public class UploadController { data.put("message", "上传失败!"); return GlobalResultGenerator.genSuccessResult(data); } - String md5 = DigestUtils.md5DigestAsHex(multipartFile.getInputStream()); + String md5 = DigestUtils.md5DigestAsHex(multipartFile.getBytes()); String orgName = multipartFile.getOriginalFilename(); String fileType = FileUtils.getExtend(orgName); String fileUrl = forestFileService.getFileUrlByMd5(md5, tokenUser.getIdUser(), fileType); @@ -190,8 +190,8 @@ public class UploadController { continue; } String fileType = FileUtils.getExtend(orgName); - try (InputStream in = multipartFile.getInputStream()) { - String md5 = DigestUtils.md5DigestAsHex(in); + try { + String md5 = DigestUtils.md5DigestAsHex(multipartFile.getBytes()); String fileUrl = forestFileService.getFileUrlByMd5(md5, tokenUser.getIdUser(), fileType); if (StringUtils.isNotEmpty(fileUrl)) { successMap.put(orgName, fileUrl); @@ -281,7 +281,7 @@ public class UploadController { return GlobalResultGenerator.genSuccessResult(data); } // 获取文件md5值 - String md5 = DigestUtils.md5DigestAsHex(inputStream); + String md5 = DigestUtils.md5DigestAsHex(getData); String fileType = "." + MimeTypeUtils.parseMimeType(conn.getContentType()).getSubtype(); String fileUrl = forestFileService.getFileUrlByMd5(md5, tokenUser.getIdUser(), fileType);