I am trying to download the splitted zip file coming from api call in parts (.zip, .z01, .z02) etc. In Javascript I want to download these files on the fly and create a combined .zip file and then save the unzipped file. (i don't need to create a combined zip) I simply need test.pdf file which which has been splitted to multiple zip. I want to download that pdf file.
e.g. test.pdf (18 mb) is splitted into two zip files of (.zip 10mb) and (.z01 8mb). currently I am downloading them as blob and then merging them. the resulting zip is currupted. below is the code I tried.
Promise.all([
axios.get(`https://testapi.com/folder/file.zip`, {
responseType: "blob",
headers: {
Accept: "application/json",
},
}),
axios.get(`https://testapi.com/folder/file.z01`, {
responseType: "blob",
headers: {
Accept: "application/json",
},
}),
]).then((obj) => {
let blob: any = [];
obj.forEach((e: any) => {
blob.push(e.data);
});
const newBlob = new Blob(blob, { type: "octet/stream" });
saveAs(newBlob, "zip.zip"); // but it's currupted
});