瀏覽代碼

多文件压缩下载 bug修复

laiguoran 4 年之前
父節點
當前提交
4d2f8ea55b
共有 2 個文件被更改,包括 3 次插入7 次删除
  1. 2 6
      app/controller/stage_controller.js
  2. 1 1
      config/config.default.js

+ 2 - 6
app/controller/stage_controller.js

@@ -1547,12 +1547,8 @@ module.exports = app => {
                     'Content-Disposition': disposition,
                     'Content-Length': size,
                 });
-                // const readStream = fs.readFileSync(path.resolve(this.app.baseDir, zipPath));
-                // ctx.body = fs.createReadStream(path.resolve(this.app.baseDir, zipPath));
-                ctx.body = fs.readFileSync(path.resolve(this.app.baseDir, zipPath));
-                // readStream.on('close', () => {
-
-                // });
+                ctx.body = fs.createReadStream(path.join(this.app.baseDir, zipPath));
+                // ctx.body = fs.readFileSync(path.resolve(this.app.baseDir, zipPath));
                 if (fs.existsSync(path.resolve(this.app.baseDir, zipPath))) {
                     fs.unlinkSync(path.resolve(this.app.baseDir, zipPath));
                 }

+ 1 - 1
config/config.default.js

@@ -135,7 +135,7 @@ module.exports = appInfo => {
     config.gzip = {
         threshold: 2048,
         // 下载的url要用正则忽略
-        ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)(\w*)/ig,
+        ignore: /(\w*)(\/download\/file)|(\/profile\/qrCode)|(\/download\/compresse-file)(\w*)/ig,
     };
 
     config.customLogger = {