|
@@ -241,12 +241,10 @@ class UtilService extends CrudService {
|
|
|
* @param {*} fn 文件名,默认为 "导出结果"
|
|
|
*/
|
|
|
async toZip(fileList, fn = '导出结果') {
|
|
|
- console.log('in function:toZip');
|
|
|
if (!_.isArray(fileList)) {
|
|
|
throw new BusinessError(ErrorCode.DATA_INVALID, '需要压缩的文件数据格式错误');
|
|
|
}
|
|
|
fn = `${fn}.zip`;
|
|
|
- console.log(`after rename=>${fn}`);
|
|
|
// zip文件夹创建
|
|
|
const { app } = this;
|
|
|
const rootPath = `${app.config.cdn.repos_root_path}`;
|
|
@@ -279,7 +277,6 @@ class UtilService extends CrudService {
|
|
|
if (uri && filename) resetFileList.push({ uri, filename });
|
|
|
}
|
|
|
// 导出
|
|
|
- console.log(`${path}${fn}`);
|
|
|
const output = fs.createWriteStream(`${path}${fn}`);
|
|
|
const archive = archiver('zip', {
|
|
|
zlib: { level: 9 },
|
|
@@ -290,11 +287,9 @@ class UtilService extends CrudService {
|
|
|
const { uri, filename } = file;
|
|
|
const res = await this.ctx.curl(`http://127.0.0.1${uri}`);
|
|
|
if (res && res.data) {
|
|
|
- console.log('in function:append');
|
|
|
archive.append(res.data, { name: filename });
|
|
|
}
|
|
|
}
|
|
|
- console.log('before finalize');
|
|
|
archive.finalize();
|
|
|
return `/files${zipPath}${fn}`;
|
|
|
}
|