I am tryint to donwload a binary file via http in nodejs. Inspired by this question, I tried this:
http.get(url,function (res) {
res.setEncoding('binary');
var body = [];
res.on("data", function (chunk) {
body.push(chunk);
});
res.on("end", function () {
result = Buffer.concat(body);
});
});
The problem is, that the chunk
data blocks are of type string, not of type buffer. For this reasons Buffer.concat(body)
fails.
Why and how can I change this?