var express = require('express');
var router = express.Router();
const fs = require('fs');
var unzip = require("unzip");
const download = require('download');
(async () => { // await download('http://172.20.33.25:8088/upload/download.action?fileName=345.zip&md5=bc09d226db664c8b362743608f6f74ca&type=zip&size=153&fileId=1264&time=1599548153286&filename=bc09d226db664c8b362743608f6f74ca.zip ', './'); fs.writeFileSync('./123.zip', await download('http://172.20.33.25:8088/upload/download.action?fileName=345.zip&md5=bc09d226db664c8b362743608f6f74ca&type=zip&size=153&fileId=1264&time=1599548153286&filename=bc09d226db664c8b362743608f6f74ca.zip')); // download('http://172.20.33.25:8088/upload/download.action?fileName=345.zip&md5=bc09d226db664c8b362743608f6f74ca&type=zip&size=153&fileId=1264&time=1599548153286&filename=bc09d226db664c8b362743608f6f74ca.zip ').pipe(fs.createWriteStream('./123.zip')); // await Promise.all([ // 'http://172.20.33.25:8088/upload/download.action?fileName=345.zip&md5=bc09d226db664c8b362743608f6f74ca&type=zip&size=153&fileId=1264&time=1599548153286&filename=bc09d226db664c8b362743608f6f74ca.zip ', // ].map(url => download(url, './'))); var extract = unzip.Extract({ path: './' }); fs.createReadStream('./123.zip').pipe(extract); extract.on('close', function () { console.log("解壓完成!!"); //刪除 fs.unlinkSync('./123.zip'); }); extract.on('error', function (err) { console.log(err); }); })();