Created
January 23, 2022 06:48
-
-
Save tanvirstreame/6cd1801607065a59966bf2f7df0848dd to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fs = require('fs') | |
| const request = require('request') | |
| const download = (url, path, callback) => { | |
| request.head(url, (err, res, body) => { | |
| request(url) | |
| .pipe(fs.createWriteStream(path)) | |
| .on('close', callback) | |
| }) | |
| } | |
| const url = 'https://…' | |
| const path = './image.png' | |
| download(url, path, () => { | |
| console.log('✅ Done!') | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment