Last active
January 27, 2017 19:57
-
-
Save Daymannovaes/54663e0718f0ded40285d0666f937179 to your computer and use it in GitHub Desktop.
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
// first run npm install -g request | |
function requestFile(url, callback) { | |
return require('request').get(url, callback); | |
} | |
let url = 'https://www.google.com.br/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'; | |
// stream test | |
requestFile(url).pipe(require('fs').createWriteStream('image-stream.png')); | |
// buffer test | |
requestFile(url, (error, response, body) => { | |
require('fs').writeFileSync('image-sync.png', body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment