Created
June 23, 2017 16:57
-
-
Save bhuizi/2f3d88ecb4a57b097c35c33e730d52eb to your computer and use it in GitHub Desktop.
http_get_zip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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