javascript - yauzl中无效的本地文件头签名错误
问题描述
我正在开发一个解压缩功能,它需要从远程目标读取 zip 文件,解压缩内容,然后通过网络将这些文件创建到目标。我正在使用 yauzl 和 RandomAccessReader 方法来读取传入流和发布事件。
const zipQueue = [];
const yauzl = new Yauzl(reader);
const zipfile = yauzl.fromRandomAccessReader(this, this.contentLength, { lazyEntries: true, autoclose: false});
zipfile.on('entry', function(entry){
zipQueue.push(entry);
zipfile.readEntry();
}).on('end', function() {
for(const entry of zipQueue) {
if(/\/$/.test(entry.fileName)) {
this.emit('directory');
} else {
const readStream = zipfile.openReadStream(entry);
this.emit('file');
}
}
})
我正在以正确的格式获取 zipfile 和条目对象,但是当我尝试打开 readStream 时,它在 30 个奇数条目后zipfile.openReadStream()
失败。invalid local file header signature: 0x8074b50
我怀疑这与比赛条件有关。有没有其他提供类似解决方案的 npm 包?
解决方案
推荐阅读
- python - 调用使用 argparse 的函数
- python - 如何只删除一次出现的键?
- python - 即使在单击下一步按钮后,脚本也会从第一页获取相同的结果
- android - 如何在Android中模拟按钮按下
- python - 在python中的字符串mongo查询中传递参数
- java - 在Android中控制音乐播放器的音乐
- c++ - 当有多个匹配可能性时,`std::regex_search` 是否有任何保证
- react-native - 将道具传递给 tabNavigator 的屏幕
- python - 试图从雅虎股票数据中打印第一个高值,得到“基于非整数索引的索引只能有非整数索引器”
- r - 用 ggplot 绘制不相似的数据