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);
    });

  })();

 

相关文章:

  • 2021-06-10
  • 2021-06-15
  • 2021-12-15
  • 2021-08-10
  • 2022-02-15
  • 2021-06-28
  • 2021-06-02
猜你喜欢
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2021-12-10
  • 2021-08-07
相关资源
相似解决方案