const fs = require('fs')//导入模块
const zlib = require('zlib')//创建压缩包
let readStream = fs.createReadStream('./input.txt')//创建输入流对象
let writeStream = fs.createWriteStream('out.txt')//创建输出流对象
readStream.pipe(writeStream);//输入流的和输出流的连接
// 压缩
let inputStream = fs.createReadStream('./out.txt')
//解压缩
inputStream.pipe(zlib.createGzip()).pipe(fs.createWriteStream('./out.zip'))
使用管道流压缩和 解压缩文件
最新推荐文章于 2024-08-30 10:02:47 发布