From 76627550133057d786c2975712709784c8ce5f88 Mon Sep 17 00:00:00 2001 From: kjh Date: Wed, 4 Sep 2024 17:51:10 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=A8=EB=B0=94=EC=9D=BC=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=A7=81=ED=81=AC=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ens/ktgbs/web/KtGbsInboundController.java | 52 +++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java b/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java index 929af55..820cce2 100644 --- a/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java +++ b/mens-api/src/main/java/kr/xit/ens/ktgbs/web/KtGbsInboundController.java @@ -1,9 +1,7 @@ package kr.xit.ens.ktgbs.web; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; @@ -14,6 +12,14 @@ import kr.xit.biz.ens.model.ktgbs.KtGbsDTO; import kr.xit.biz.ktgbs.service.IBizKtGbsService; import lombok.RequiredArgsConstructor; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + /** *
  * description : KT GBIS 에서 사용 되는 API
@@ -78,4 +84,44 @@ public class KtGbsInboundController {
     public KtCommonDTO.KtCommonResponse messageResult(@RequestBody final KtGbsDTO.MsgRsltRequest reqDTO) {
         return bizService.messageResult(reqDTO);
     }
+
+    @Operation(summary = "링크이미지 출력")
+    @GetMapping(value = "/goji/sys/util/lnk/img")
+    public void printImg(HttpServletRequest request, HttpServletResponse response, @RequestParam String link, @RequestParam String type) throws IOException {
+
+        String mime = null;
+        if ("jpg".equals(type) || "jpeg".equals(type))
+            mime = "image/jpeg";
+        else if ("png".equals(type))
+            mime = "image/png";
+        else if ("gif".equals(type))
+            mime = "image/gif";
+        else
+            mime = "image/jpeg";
+
+
+        try (InputStream inputStream = new URL(link).openStream();
+             ServletOutputStream outputStream = response.getOutputStream();) {
+
+            response.setHeader("Cache-Control", "no-store");
+            response.setHeader("Pragma", "no-cache");
+            response.setDateHeader("Expires", 0);
+            response.setContentType(mime);
+
+
+            int length;
+            byte[] buffer = new byte[1024];
+            while ((length = inputStream.read(buffer)) != -1) {
+                outputStream.write(buffer, 0, length);
+            }
+
+
+            outputStream.flush();
+
+        } catch (FileNotFoundException e) {
+            response.getWriter().println("File is Not Found." + e.getMessage());
+        } catch (IOException e) {
+            response.getWriter().println("I/O Error Occurred!!. " + e.getMessage());
+        }
+    }
 }