Decompressing data results in an invalid blob #119
-
|
I am developing a web application which has to exchange large files between back-end and front-end. For this reason, on the back-end I have developed an algorithm in python to create a zip file with a single file inside it (no folders). Then, on the front-end side, I download this file and I tried to decompress it in two different ways: using JSZip and fflate. With JSZip the decompression happens correctly but it is rather slow while with fflate the decompression happens very quickly without errors but this generates a small and wrong Blob object. Here are the two javascript algorithms I use for decompression: Am I wrong in using the library? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
This is a similar issue to #111. You can't use 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); |
Beta Was this translation helpful? Give feedback.
This is a similar issue to #111. You can't use
decompressSyncfor ZIP files, you need to useunziporunzipSync. Here's some code that should work: