Browse Source

压缩文件名字修改

yingp 7 years ago
parent
commit
368a376676

+ 2 - 0
base-servers/file/file-server/src/main/java/com/usoftchina/saas/file/controller/FileController.java

@@ -115,6 +115,8 @@ public class FileController {
     private void download(FileInfo info, HttpServletResponse response) throws Exception{
         response.setContentType("application/force-download");
         if (info.isFolder()) {
+            response.setHeader("Content-disposition",
+                    "attachment; filename=" + URLEncoder.encode(info.getName() + ".zip", "UTF-8"));
             // 压缩后下载
             try (ArchiveOutputStream out = new ZipArchiveOutputStream(response.getOutputStream());) {
                 cascadeOutput(info, null, out);