From 3904f196da827c761777b7153c640cfe6dc4d99a Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Thu, 14 Sep 2023 13:18:29 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A9=94=EB=89=B4=EC=96=BC=20=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EB=A1=9C=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cokr/xit/fims/base/FileController.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/main/java/cokr/xit/fims/base/FileController.java b/src/main/java/cokr/xit/fims/base/FileController.java index ab0de0f2..51c7cebc 100644 --- a/src/main/java/cokr/xit/fims/base/FileController.java +++ b/src/main/java/cokr/xit/fims/base/FileController.java @@ -1,13 +1,11 @@ package cokr.xit.fims.base; -import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.io.StringWriter; import java.net.URISyntaxException; import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -21,9 +19,9 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Controller; -import org.springframework.util.ResourceUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; import org.w3c.dom.Document; @@ -33,11 +31,9 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.dao.FileMapper; import cokr.xit.base.file.service.FileQuery; import cokr.xit.base.file.service.bean.FileBean; -import cokr.xit.base.file.web.FileInfoFactory; @Controller public class FileController extends cokr.xit.base.file.web.FileController { @@ -62,14 +58,17 @@ public class FileController extends cokr.xit.base.file.web.FileController { */ @GetMapping(name = "메뉴얼 다운로드", value = "/downloadMenual.do") public ModelAndView downloadMenual() throws Exception { - String filePath = ("classpath:menual/메뉴얼.pptx"); - File file = ResourceUtils.getFile(filePath); - ModelAndView mav = new ModelAndView("downloadView"); - List files = new ArrayList<>(); - files.add(file); - List fileInfos = new FileInfoFactory().createFileInfos(null, files); - FileInfo fileInfo = fileInfos.get(0); - mav.addObject("file", fileInfo); + ModelAndView mav = new ModelAndView("downloadView"); + + String filePath = ("menual/메뉴얼.pptx"); + ClassPathResource cps = new ClassPathResource(filePath); + InputStream menualIS = cps.getInputStream(); + + mav.addObject("file", menualIS); + mav.addObject("filename", "메뉴얼.pptx"); + mav.addObject("contentType", "application/vnd.openxmlformats-officedocument.presentationml.presentation"); + mav.addObject("length", menualIS.available()); + return mav; }