Need code of create zip download with large image size files #85
Answered
by
101arrowz
sannysoni123
asked this question in
Q&A
-
Hi All, Regards, |
Beta Was this translation helpful? Give feedback.
Answered by
101arrowz
Sep 3, 2021
Replies: 1 comment 3 replies
-
In what form are your files? If they are import { zipSync } from 'fflate';
const downloadZip = async () => {
// As long as these are Blob objects it is fine
const image1Blob = new Blob([pngData], { type: 'image/png' });
const image2Blob = new Blob([jpgData], { type: 'image/jpeg' });
const zip = zipSync({
// Ultimately the input should be Uint8Array
// If you don't have Blob objects, find some other way to make the data Uint8Array
'image1.png': new Uint8Array(await image1Blob.arrayBuffer()),
'image2.jpeg': new Uint8Array(await image2Blob.arrayBuffer())
}, { level: 0 });
// Level 0 disables compression
// Temporary URL that contains blob
const url = URL.createObjectURL(new Blob([zip]));
const fakeLink = document.createElement('a');
fakeLink.href = url;
fakeLink.download = 'filename.zip';
// Download the ZIP file automatically
fakeLink.click();
URL.revokeObjectURL(url);
} If you're looking for maximum performance or are streaming the files (e.g. downloading multiple images and creating a ZIP from them as you download), read the documentation in the README and the wiki. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
sannysoni123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In what form are your files? If they are
Blob
objects: