1

下载大于 4GB 的文件时出现标题错误,无论是否使用“forceZip64”选项。当逐个流式传输每个文件内容时,会在旅途中生成 zip。

如何创建 zip 文件

// create zip archive
const zip = Archiver.create('zip', {
    store: true
    // forceZip64: contentLength > 4 * 1024 * 1024 * 1024
});
// pipe zip to response
zip.pipe(response);

// iterate targets download
for (const files of file) {
   const stream = await this.downloadFile(file.source); // returns Readable
   zip.append(stream, { name: file.source.filename });

   // await to download files one by one.
   await new Promise((resolve, reject) => {
      // handle success
      stream.on('end', () => {
          resolve();
      });
      // handle error
      stream.on('error', (err) => {
          reject();
      });
   });
}

// finalize zip streaming
zip.finalize();

zip文件是如何解压的

使用 7ZIP Ubuntu

  • 例如,当我下载一个大于 4GB 的文件,然后我尝试使用 7zip 解压缩它时,我将得到以下输出:
7-Zip (a) [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM) i7-7700T CPU @ 2.90GHz (906E9),ASM,AES-NI)

Scanning the drive for archives:
1 file, 15587398396 bytes (15 GiB)

Extracting archive: files.zip

ERRORS:
Headers Error

--
Path = files.zip
Type = zip
ERRORS:
Headers Error
Physical Size = 15587398396
64-bit = +

使用解压缩Mac OS 和 Ubuntu(2009 年 4 月 20 日的解压缩 6.00)

  • 我不会收到任何错误

归档实用程序Mac OS

  • “无法将 'files.zip' 扩展为 'Downloads'。”
  • “(错误 2 - 没有这样的文件或目录)”

结果

解压缩程序总是可以工作,7ZIP抱怨标题,但最后解压缩得很好,存档实用程序(Mac Os 默认)无法解压缩文件。

在所有情况下,MD5 校验和都与原始校验和匹配。

有没有人遇到过大于 4GB (2^32B) 的文件的这种问题?

我对 4GB 以下的 zip 所做的一切都是成功的,并且没有任何类型的错误或警告。

4

0 回答 0