Search code examples
javascripthtmlnode.jsjszip

Does google chorme version 75 support .arrayBuffer()?


Help me, Does google chorme version 75 support .arrayBuffer()?. In Google Chrome version 75, the function .arrayBuffer is reported as not being a function

I have tested it on higher versions, and .arrayBuffer works normally. And here is the piece of code that I use involving .arrayBuffer(): Array.from(file.files).forEach((f, i) => { zip.file(f.webkitRelativePath, f.arrayBuffer()) })


Solution

  • It is not supported in version 75. Instead you can try this I think it will work

    Array.from(file.files).forEach((f, i) => {
      const reader = new FileReader();
      reader.onload = function (e) {
        // e.target.result contains the file contents as an ArrayBuffer
        zip.file(f.webkitRelativePath, e.target.result);
      };
      reader.readAsArrayBuffer(f);
    });