From 1c61862ae3569996632b7d205dd53e02a76d8019 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Tue, 14 Mar 2023 10:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E8=B4=A8=E8=AF=81=E4=B9=A6=E9=A2=84?= =?UTF-8?q?=E8=A7=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/glxp/api/upload/DownloadController.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/glxp/api/upload/DownloadController.java b/src/main/java/com/glxp/api/upload/DownloadController.java index 54877f49..7b25ef4a 100644 --- a/src/main/java/com/glxp/api/upload/DownloadController.java +++ b/src/main/java/com/glxp/api/upload/DownloadController.java @@ -1,5 +1,6 @@ package com.glxp.api.upload; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -14,16 +15,18 @@ import java.io.OutputStream; @RestController public class DownloadController { + @Value("${file_path}") + private String filePath; @GetMapping(value = "/udiwms/image/register/file/getImage") public void getImage(HttpServletResponse response , @RequestParam String type , @RequestParam String name) throws IOException { - if (name.endsWith("pdf")) { + if (name.endsWith("pdf") || name.endsWith("doc")) { OutputStream os = null; try { - FileInputStream input = new FileInputStream(new File("d:/1s/udiwms/register/file/" + type + "/" + name)); + FileInputStream input = new FileInputStream(new File(filePath + "/register/file/" + type + "/" + name)); OutputStream out = response.getOutputStream(); byte[] b = new byte[2048]; int len; @@ -44,7 +47,7 @@ public class DownloadController { try { // 读取图片 BufferedImage image = ImageIO.read( - new FileInputStream(new File("d:/1s/udiwms/register/file/" + type + "/" + name))); + new FileInputStream(new File(filePath + "/register/file/" + type + "/" + name))); response.setContentType("image/png"); os = response.getOutputStream();