From b6fd093def92b3a538932c6cb808c94fa6275fa1 Mon Sep 17 00:00:00 2001 From: Jinquan_Ou <Jinquan@gdut.com> Date: 星期一, 27 三月 2023 22:01:29 +0800 Subject: [PATCH] 加上url --- zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java index af2b9e1..866a6b5 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/DownLoadFileServiceImpl.java @@ -2,6 +2,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.service.DownLoadFileService; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.servlet.http.HttpServletResponse; @@ -14,9 +15,14 @@ */ @Service public class DownLoadFileServiceImpl implements DownLoadFileService { - @Override - public AjaxResult downLoadFile(String path, HttpServletResponse response) { + @Value("${ruoyi.profile}") + private String basePath; + + @Override + public void downLoadFile(String path, HttpServletResponse response) { + + path=basePath+path.substring(8); File file = new File(path); byte[] buffer = new byte[1024]; BufferedInputStream bis = null; @@ -34,7 +40,6 @@ while(bis.read(buffer) != -1){ os.write(buffer); } - return AjaxResult.success("鎿嶄綔鎴愬姛"); } }catch (Exception e) { e.printStackTrace(); @@ -51,6 +56,5 @@ e.printStackTrace(); } } - return AjaxResult.error("鎿嶄綔澶辫触"); } } -- Gitblit v1.9.1