From a77b5cd0e8d4897463e811d11e962a31ed07f997 Mon Sep 17 00:00:00 2001 From: lijiarao Date: Fri, 29 Oct 2021 10:01:05 +0800 Subject: [PATCH] =?UTF-8?q?fix=20bug=2041161=20=E3=80=90ie=E3=80=91?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=87=BA=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/system/controller/CommonController.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java b/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java index d7ad456a..3903d437 100644 --- a/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java +++ b/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import com.jero.common.api.vo.Result; import com.jero.common.constant.CommonConstant; import com.jero.common.system.api.ISysBaseAPI; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -170,7 +171,10 @@ public class CommonController { response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); response.setContentType("application/force-download");// 设置强制下载不打开 if (type == null) { - if (fileName.contains(".jpg") || fileName.contains(".png") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + fileName = StringUtils.lowerCase(fileName); + if (fileName.contains(".jpg") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + response.setContentType("image/jpeg;image/jpg;image/gif;image/png"); + } else if (fileName.contains(".png")) { response.setContentType("image/png;image/jpg;image/gif;image/jpeg"); } } @@ -279,7 +283,10 @@ public class CommonController { response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); response.setContentType("application/force-download");// 设置强制下载不打开 if (type == null) { - if (fileName.contains(".jpg") || fileName.contains(".png") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + fileName = StringUtils.lowerCase(fileName); + if (fileName.contains(".jpg") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + response.setContentType("image/jpeg;image/jpg;image/gif;image/png"); + } else if (fileName.contains(".png")) { response.setContentType("image/png;image/jpg;image/gif;image/jpeg"); } }