-
Hi, I'm trying to unzip an uploaded file and rezip it afterwards. I'm using an input (type=file) and this code gets called when the file changes: <input className={styles.input} type="file" onChange={e => setFile(e.target.files[0])}/>
...
import * as fflate from "fflate";
...
if (file != null) {
const fr = new FileReader(file);
fr.addEventListener('load', (e) => {
const uint8 = new Uint8Array(e.target.result);
let unzipped = fflate.unzipSync(uint8);
const newZip = fflate.zipSync(unzipped);
const blob = new Blob([newZip], {type: "application/zip"});
const objectUrl = URL.createObjectURL(blob);
window.open(objectUrl);
})
fr.readAsArrayBuffer(file); Somehow, I can't open the file anymore after downloading it. I also noticed that the output file is significantly bigger than the original one. What could be the reason? |
Beta Was this translation helpful? Give feedback.
Answered by
101arrowz
Jan 12, 2021
Replies: 1 comment 1 reply
-
My mistake, I was forgetting to add the data into the file in the synchronous ZIP function, but I only tested the asynchronous version. Will push an update soon. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
101arrowz
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My mistake, I was forgetting to add the data into the file in the synchronous ZIP function, but I only tested the asynchronous version. Will push an update soon.