我正在使用 ZLibDeflater 压缩文件,将其作为流读取并进行转换:
new File(filePath)
.openRead()
.transform(new ZLibDeflater())
.pipe(new File(gzipPath).openWrite())
.then(...);
您还可以使用ZLIB:
new File(filePath)
.openRead()
.transform(ZLIB.decoder)
.pipe(new File(zlibPath).openWrite())
.then(...);
尽早放弃,您可以使用Converter.bind()
转换流的方法简单地做到这一点:
const GZipCodec()
.encoder.bind(new File(filePath).openRead())
.pipe(new File(gzipPath).openWrite())
.then(...)