javascript – What modules to implement uploading and downloading images in Node.js?

Question:

The user uploads the avatar via node.js to the remote file system next to the database, after which each session uploads it back. Which node.js modules can be used to transfer one-time jpg files?

Answer:

One can use node-wget :

var wget = require('node-wget')

var url = "https://www.gravatar.com/avatar/cbfaff96665b7567defe1b34a883db8b?s=256&d=identicon&r=PG"
var dest = "./picture.png"

wget({ url, dest }, (error, response, body) => {
  if (error) throw error
  console.log("Downloaded")
})
Scroll to Top