如何转换' fflate的累积数据'拉链流到斑点供下载

发布于 2025-01-23 09:33:19 字数 906 浏览 3 评论 0原文

该应用程序将在GB中创建大数据。存储到阵列并传递给Zip()的限制后,堆填充了。因此,我的计划是

  • 使用zipdeflate .push()
  • ondata商店
  • 转换每行,以将数组转换为blob,可以将其保存为zip文件

findings

  • 数据是一个uint8array
  • new blob([MergedDatas])不是zip文件
  const zippedData = []
  const zip = new Zip();
  zip.ondata = (err, data, final) => {
        if (!err) {
          zippedData.push(data)
          if (final) {
            // Here I want the zipped data to be downloaded
          }
        }
      };
    
  const frames = new ZipDeflate(exportName + '.lsf', {
    level: 9,
  });
 zip.add(frames);
 frames.push(header); // this is a uintd binary data
// there is lot of loops and things that will generate GBs of data eg. below two lines
 frames.push(numberToBytes(branch.name));
 frames.push(ColorByteArray);
// end of loop 
 frames.push(new Uint8Array(0), true);
 zip.end();

The application will create a large data in GBs. After storing to an array and the passing to zip() worked to a limit , which the heap filled. So my plan is

  • convert each line using ZipDeflate .push()
  • ondata store to an array
  • convert the array to blob that can be saved as a zip file

findings

  • data is an Uint8Array
  • new Blob([mergedDatas]) was not a zip file
  const zippedData = []
  const zip = new Zip();
  zip.ondata = (err, data, final) => {
        if (!err) {
          zippedData.push(data)
          if (final) {
            // Here I want the zipped data to be downloaded
          }
        }
      };
    
  const frames = new ZipDeflate(exportName + '.lsf', {
    level: 9,
  });
 zip.add(frames);
 frames.push(header); // this is a uintd binary data
// there is lot of loops and things that will generate GBs of data eg. below two lines
 frames.push(numberToBytes(branch.name));
 frames.push(ColorByteArray);
// end of loop 
 frames.push(new Uint8Array(0), true);
 zip.end();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灵芸 2025-01-30 09:33:19

终于发现自己


  let processedZipStreams = [];
  zip.ondata = async (err, dat, final) => {
    if (err) {
    } else {
      processedZipStreams.push(dat);
      generatorInstance.next();
      if (final) {
        SaveAs(
          new Blob(processedZipStreams, { type: 'application/octet-stream' }),
          exportName,
          true
        );
        callback(100);
        const duration = performance.now() - start;
        console.log(duration / 1000);
      }
    }
  };

处理的邮政流可以包装到斑点并下载

Finally found myself


  let processedZipStreams = [];
  zip.ondata = async (err, dat, final) => {
    if (err) {
    } else {
      processedZipStreams.push(dat);
      generatorInstance.next();
      if (final) {
        SaveAs(
          new Blob(processedZipStreams, { type: 'application/octet-stream' }),
          exportName,
          true
        );
        callback(100);
        const duration = performance.now() - start;
        console.log(duration / 1000);
      }
    }
  };

processed ZipStreams can be packed to a blob and downloaded

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文