Compress into .zip file with node.js core zlib module

血红的双手。 提交于 2020-01-24 07:35:00

问题


How can I compress a file/files and save into a .zip extension file with the provided node.js zlib module? I figured how to save into .gz using gzip like the following:

const gzip = zlib.createGzip();
const fs = require('fs');
const input = fs.createReadStream('myfile.txt');
const out = fs.createWriteStream('myfile.txt.gz');

input.pipe(gzip).pipe(out);

来源:https://stackoverflow.com/questions/48638885/compress-into-zip-file-with-node-js-core-zlib-module

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!