我正在使用ZLibDeflater来压缩文件,将其作为流读取并对其进行转换:
new File(filePath)
.openRead()
.transform(new ZLibDeflater())
.pipe(new File(gzipPath).openWrite())
.then(...);
作为ZLibDeflater is now deprecated,如何将代码转换为使用新的GZipCodec类?
答案 0 :(得分:4)
您还可以使用ZLIB:
new File(filePath)
.openRead()
.transform(ZLIB.decoder)
.pipe(new File(zlibPath).openWrite())
.then(...);
答案 1 :(得分:0)
尽早提前,您只需使用Converter.bind()
方法转换流即可:
const GZipCodec()
.encoder.bind(new File(filePath).openRead())
.pipe(new File(gzipPath).openWrite())
.then(...)