Skip to content
Discussion options

You must be logged in to vote

This is a similar issue to #111. You can't use decompressSync for ZIP files, you need to use unzip or unzipSync. Here's some code that should work:

import { unzip } from 'fflate';

const uint8Array = new Uint8Array(await blob.arrayBuffer());
const unzipped = await new Promise((resolve, reject) => {
  unzip(uint8Array, (err, result) => err ? reject(err) : resolve(result));
});
// The above code decompresses in another thread, which prevents UI freezing
// If your files are relatively small, this may be faster:
// const unzipped = unzipSync(uint8Array);

const fileBuffer = Object.values(unzipped)[0];
let out = new Blob([fileBuffer]);
console.log(out.size);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 101arrowz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants