Skip to content

Instantly share code, notes, and snippets.

@bhuizi
Created June 23, 2017 16:57
Show Gist options
  • Save bhuizi/2f3d88ecb4a57b097c35c33e730d52eb to your computer and use it in GitHub Desktop.
Save bhuizi/2f3d88ecb4a57b097c35c33e730d52eb to your computer and use it in GitHub Desktop.
http_get_zip
const http = require('http');
const fs = require('fs');
http.get(<path_to_zip_file>, (res) => {
const statusCode = res.statusCode;
const contentType = res.headers['content-type'];
let error;
if(statusCode !== 200){
console.log(`Request failed, status code ${statusCode}`);
} else {
res.pipe(fs.createWriteStream('the.zip'))
res.on('end', () => {
console.log('closing');
})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment