download binary files in express code example
Example: download binary files in express
var options = {
method: 'GET',
host: 'localhost',
port: port,
path: '/file'
};
var request = http.request(options, function(response) {
var data = [];
response.on('data', function(chunk) {
data.push(chunk);
});
response.on('end', function() {
data = Buffer.concat(data); // do something with data
});
});
request.end();