How to remove an entry from a zip file and create a new Blob from the modified zip file #458
Unanswered
Suraj-Gharat-Clario
asked this question in
Q&A
Replies: 1 comment
-
I think this might help you. I used something similar to modify a specific file and add it to a new Zip file. const zipFileWriter = new BlobWriter();
const zipFileReader = new BlobReader(file);
const zipWriter = new ZipWriter(zipFileWriter);
const zipReader = new ZipReader(zipFileReader);
const entries = await zipReader.getEntries();
const specificFile = 'XXX.tmp';
for (const entry of entries) {
if (entry.filename.endsWith(specificFile)) {
// Do nothing here, since you want to remove the file
} else {
const writer = new BlobWriter();
const data = await entry.getData!(writer);
await zipWriter.add(entry.filename, new BlobReader(data));
}
}
await zipWriter.close();
const newZipFileBlob = await zipFileWriter.getData(); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to remove a zip entry from a zip file which user has selected zip file and create a new Blob from the modified zip. I've encountered an issue while implementing the code as follows:
Any help or suggestions you can provide would be invaluable to me.
Beta Was this translation helpful? Give feedback.
All reactions