Created
August 7, 2018 11:12
-
-
Save oguzcan-yavuz/6a7bd06699226f92e24cb6999c2e8803 to your computer and use it in GitHub Desktop.
node download example
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
// https://stackoverflow.com/questions/12740659/downloading-images-with-node-js | |
const fs = require('fs'), | |
request = require('request') | |
function download(uri, filename, callback){ | |
request(uri).pipe(fs.createWriteStream(filename)).on('close', callback) | |
} | |
download('https://www.google.com/images/srpr/logo3w.png', 'google.png', function(){ | |
console.log('done') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment