疯狂的狮子li
2021-06-24 66f453452e3fd0985c581d762d63feccaef08d8e
fix 相对路径下载问题
已修改1个文件
10 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java
@@ -18,6 +18,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@@ -51,13 +52,13 @@
            }
            String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
            String filePath = RuoYiConfig.getDownloadPath() + fileName;
            File file = new File(filePath);
            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
            FileUtils.setAttachmentResponseHeader(response, realFileName);
            FileUtils.writeToStream(filePath, response.getOutputStream());
            FileUtils.writeToStream(file, response.getOutputStream());
            if (delete)
            {
                FileUtils.del(filePath);
                FileUtils.del(file);
            }
        }
        catch (Exception e)
@@ -110,8 +111,9 @@
            // 下载名称
            String downloadName = StrUtil.subAfter(downloadPath, "/",true);
            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
            File file = new File(downloadPath);
            FileUtils.setAttachmentResponseHeader(response, downloadName);
            FileUtils.writeToStream(downloadPath, response.getOutputStream());
            FileUtils.writeToStream(file, response.getOutputStream());
        }
        catch (Exception e)
        {