在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  網(wǎng)絡(luò)安全  HTML/ nodejs 中的Stream流如何復(fù)制使用呢

nodejs 中的Stream流如何復(fù)制使用呢

比如下面的代碼
stream 在使用后就會被消費(fèi)掉,但是我想多次操作這個stream,該怎么解決呢,我下面的代碼是通過fs方式再次獲得,但是io太過于頻繁了

 const stream = await ctx.getFileStream();
      const fs = require('fs');
      const qhash = '123123';
      // 寫文件
      await new Promise(resolve =>
        stream
          .pipe(fs.createWriteStream(`upload/${qhash}.zip`))
          .on('finish', resolve));
      getManifest(`upload/${qhash}.zip`);
      const stream2 = await fs.createReadStream(`upload/${qhash}.zip`);
      const sssssshash = await qetag(stream2);
      const stream3 = await fs.createReadStream(`upload/${qhash}.zip`);
      // console.log(buffer);

   
回答
編輯回答
朕略傻

試一下stream.PassThrough
參考:https://stackoverflow.com/que...

2017年6月11日 16:32