i have a Node application (called MiddleOne) from which I hit my other Node App (called BiServer). the BiServer has only 1 route as follows
app.get("/", (req, res) => {
const file = `./zipFiles.zip`;
return res.download(file);
});
"MiddleOne" App sends request to "BiServer" and gets the file(a .zip file containing a single .json file) however i am not able to reconstruct and save that .zip file on my "MiddleOne" server .
http
.get("BiServer:3009", resp => {
let data = "";
resp.on("data", chunk => {
data += chunk;
});
resp.on("end", () => {
fs.writeFile("./filename.zip", data, err => {
console.log(err ? "Error: " + err : "File saved");
return res.send("file is saved on server");
});
});
})
.on("error", err => {
console.log("Error: " + err.message);
});
the data object above has following content:
"PK
�T6P zipFiles/PK�T6P�E8FIzipFiles/zipFiles.json����R*K-*���S�RP�s
W�
��$VZ(Y))股k^zQ�Bjnbf�Bf�BAbq�/W-//PK
�T6P $zipFiles/
�c�����c����&�8����PK�T6P�E8FI$ 'zipFiles/zipFiles.json
K�#����K�#����H�����PK��"
on opening the newly created file error comes that the "file is corrupted" . how can i reconstruct the zip file on receiving response from other server ?