使用带12mb文件大小的unzip时出错

时间:2022-06-11 16:04:42

Im using the following open source to unzip file and its working as expected on zip with size 2-5 MB but when I put zip on 10 more MB I got error, there is more stable open source which I can use for large zip files? I need it to be under MIT license. this is what I've used https://github.com/EvanOxfeld/node-unzip

我使用下面的开源文件来解压zip文件,它的工作原理与大小为2-5 MB的zip一样,但是当我把zip压缩到10 MB的时候,我就有了错误,有更稳定的开源,我可以用它来做大的zip文件吗?我需要得到麻省理工学院的许可。这就是我使用的https://github.com/EvanOxfeld/node-unzip

var extractor = unzip.Extract({ path: "../"});

extractor.on("close", function() {
    console.log("Success unzip");
});

extractor.on("close", function(err) {
    console.log(err);
});

req.pipe(extractor);

2 个解决方案

#1


5  

according to this issue of the unzip github page - https://github.com/EvanOxfeld/node-unzip/issues/73,

根据本期的unzip github页面——https://github.com/EvanOxfeld/node-unzip/issues/73,

  • the unzip module is not supported anymore.
  • 不再支持unzip模块。
  • a problem related to streaming from http seem to have been solved in a fork called unzip2 (which is also very old)
  • 与http流相关的一个问题似乎已经在一个名为unzip2的分支中得到了解决(它也非常古老)

try with

试着用

npm install unzip2

there are also other zip MIT modules you can try :

你也可以尝试其他的zip MIT模块:

you can also find this library - https://www.npmjs.com/package/yauzl which explains why the 'zip' file format is not very well suited to streaming.

您还可以找到这个库——https://www.npmjs.com/package/yauzl,它解释了为什么“zip”文件格式不太适合流媒体。

https://www.npmjs.com/package/yauzl#no-streaming-unzip-api

https://www.npmjs.com/package/yauzl no-streaming-unzip-api

Due to the design of the .zip file format, it's impossible to interpret a .zip file from start to finish (such as from a readable stream) without sacrificing correctness. The Central Directory, which is the authority on the contents of the .zip file, is at the end of a .zip file, not the beginning. A streaming API would need to either buffer the entire .zip file to get to the Central Directory before interpreting anything (defeating the purpose of a streaming interface), or rely on the Local File Headers which are interspersed through the .zip file. However, the Local File Headers are explicitly denounced in the spec as being unreliable copies of the Central Directory, so trusting them would be a violation of the spec.

由于.zip文件格式的设计,从开始到结束(例如从可读的流)解释.zip文件是不可能不牺牲正确性的。中心目录是.zip文件内容的权威,位于.zip文件的末尾,而不是开头。流API需要缓冲整个.zip文件,以便在解释任何内容之前到达中心目录(这违背了流接口的目的),或者依赖于本地文件头,这些头在.zip文件中穿插。但是,规范中明确指出本地文件头是不可靠的*目录副本,因此信任它们将违反规范。

Any library that offers a streaming unzip API must make one of the above two compromises, which makes the library either dishonest or nonconformant (usually the latter). This library insists on correctness and adherence to the spec, and so does not offer a streaming API.

任何提供流式unzip API的库都必须做出上述两个妥协之一,这使得库要么不诚实,要么不符合(通常是后者)。这个库坚持规范的正确性和一致性,因此不提供流API。

there are 354 results to "unzip" on NPM - https://www.npmjs.com/search?q=unzip

NPM上有354个“unzip”结果——https://www.npmjs.com/search?q=unzip

whatever library you choose, make sure to first write a node.js program using this library that extracts the content of you errored zip file directly from the filesystem.

无论您选择什么库,请确保首先编写一个节点。使用这个库的js程序,该库直接从文件系统中提取出错的zip文件的内容。

Once this works, you will be able to add the web server additional complexity.

一旦这一操作成功,您将能够添加web服务器额外的复杂性。

#2


1  

i would use the CloudConvert api they have an npm that can handle this. the example code for it can be found in their documentation the node specific example is this

我会使用CloudConvert api他们有一个npm可以处理这个。它的示例代码可以在文档中找到,特定于节点的示例是这样的

var fs = require('fs'),
    cloudconvert = new (require('cloudconvert'))(''); // install using 'npm install cloudconvert'

fs.createReadStream('input.format').pipe(cloudconvert.convert({
"input": "upload"
}).on('error', function(err) {
    console.error('Failed: ' + err);
}).on('finished', function(data) {
    console.log('Done: ' + data.message);
    this.pipe(fs.createWriteStream('output.format'));
}).on('downloaded', function(destination) {
    console.log('Downloaded to: ' + destination.path);
}));

you do need internet connection in order for this to work. As for the MIT license obviously this is an api not independent code. But the functionality and reliability of it are going to be more then anything on the local system. And it is free if that is your worry about the MIT license. If your wanting an MIT license so you can edit it and manipulate it this might not work.

你确实需要互联网连接才能让它工作。对于麻省理工的许可显然这是一个api而不是独立的代码。但是它的功能和可靠性将比本地系统上的任何东西都重要。这是免费的,如果你担心麻省理工学院的许可证。如果你想要一个麻省理工学院的许可证,你可以编辑它并操作它,这可能行不通。

#1


5  

according to this issue of the unzip github page - https://github.com/EvanOxfeld/node-unzip/issues/73,

根据本期的unzip github页面——https://github.com/EvanOxfeld/node-unzip/issues/73,

  • the unzip module is not supported anymore.
  • 不再支持unzip模块。
  • a problem related to streaming from http seem to have been solved in a fork called unzip2 (which is also very old)
  • 与http流相关的一个问题似乎已经在一个名为unzip2的分支中得到了解决(它也非常古老)

try with

试着用

npm install unzip2

there are also other zip MIT modules you can try :

你也可以尝试其他的zip MIT模块:

you can also find this library - https://www.npmjs.com/package/yauzl which explains why the 'zip' file format is not very well suited to streaming.

您还可以找到这个库——https://www.npmjs.com/package/yauzl,它解释了为什么“zip”文件格式不太适合流媒体。

https://www.npmjs.com/package/yauzl#no-streaming-unzip-api

https://www.npmjs.com/package/yauzl no-streaming-unzip-api

Due to the design of the .zip file format, it's impossible to interpret a .zip file from start to finish (such as from a readable stream) without sacrificing correctness. The Central Directory, which is the authority on the contents of the .zip file, is at the end of a .zip file, not the beginning. A streaming API would need to either buffer the entire .zip file to get to the Central Directory before interpreting anything (defeating the purpose of a streaming interface), or rely on the Local File Headers which are interspersed through the .zip file. However, the Local File Headers are explicitly denounced in the spec as being unreliable copies of the Central Directory, so trusting them would be a violation of the spec.

由于.zip文件格式的设计,从开始到结束(例如从可读的流)解释.zip文件是不可能不牺牲正确性的。中心目录是.zip文件内容的权威,位于.zip文件的末尾,而不是开头。流API需要缓冲整个.zip文件,以便在解释任何内容之前到达中心目录(这违背了流接口的目的),或者依赖于本地文件头,这些头在.zip文件中穿插。但是,规范中明确指出本地文件头是不可靠的*目录副本,因此信任它们将违反规范。

Any library that offers a streaming unzip API must make one of the above two compromises, which makes the library either dishonest or nonconformant (usually the latter). This library insists on correctness and adherence to the spec, and so does not offer a streaming API.

任何提供流式unzip API的库都必须做出上述两个妥协之一,这使得库要么不诚实,要么不符合(通常是后者)。这个库坚持规范的正确性和一致性,因此不提供流API。

there are 354 results to "unzip" on NPM - https://www.npmjs.com/search?q=unzip

NPM上有354个“unzip”结果——https://www.npmjs.com/search?q=unzip

whatever library you choose, make sure to first write a node.js program using this library that extracts the content of you errored zip file directly from the filesystem.

无论您选择什么库,请确保首先编写一个节点。使用这个库的js程序,该库直接从文件系统中提取出错的zip文件的内容。

Once this works, you will be able to add the web server additional complexity.

一旦这一操作成功,您将能够添加web服务器额外的复杂性。

#2


1  

i would use the CloudConvert api they have an npm that can handle this. the example code for it can be found in their documentation the node specific example is this

我会使用CloudConvert api他们有一个npm可以处理这个。它的示例代码可以在文档中找到,特定于节点的示例是这样的

var fs = require('fs'),
    cloudconvert = new (require('cloudconvert'))(''); // install using 'npm install cloudconvert'

fs.createReadStream('input.format').pipe(cloudconvert.convert({
"input": "upload"
}).on('error', function(err) {
    console.error('Failed: ' + err);
}).on('finished', function(data) {
    console.log('Done: ' + data.message);
    this.pipe(fs.createWriteStream('output.format'));
}).on('downloaded', function(destination) {
    console.log('Downloaded to: ' + destination.path);
}));

you do need internet connection in order for this to work. As for the MIT license obviously this is an api not independent code. But the functionality and reliability of it are going to be more then anything on the local system. And it is free if that is your worry about the MIT license. If your wanting an MIT license so you can edit it and manipulate it this might not work.

你确实需要互联网连接才能让它工作。对于麻省理工的许可显然这是一个api而不是独立的代码。但是它的功能和可靠性将比本地系统上的任何东西都重要。这是免费的,如果你担心麻省理工学院的许可证。如果你想要一个麻省理工学院的许可证,你可以编辑它并操作它,这可能行不通。