I wanted to allow user to modify a zip file which they uploaded and then submit it to the server. My UI is made using react js and I am using JsZip library to do it.
var zip = new JSZip();
let myZip = null;
zip.loadAsync(f).then( zipFile => {
Object.keys(zipFile.files).forEach(filename => {
zip.file(filename, text);
myZip = zipFile.generateAsync({type : "string"}).then(function (blob) {
myZip = new File([blob], "hello.zip");
});
;
})
});
Note:The zip has just one file at entry level. Rest are inside a folder.
Problem is that I am unable to create the final zip using generateAsync function. The myZip object is null.
Any help is appreciated. Thanks.