14-Oct-2022
.
Admin
This tutorial is focused on node js download file from url. In this article, we will implement a how to download file from url in node.js. step by step explain node js download file from url https. I’m going to show you about node js download file from url and save.
I will give you a simple example of download a file using nodejs. In this example download a file using the download npm package in node js. There are multiple ways to download and save a file to the local filesystem in Nodejs.
So let's start following example with output:
Step 1: Install Node JS
This step is not required; however, if you have not created the node js app, then you may go ahead and execute the below command:
mkdir my-app
cd my-app
npm init
Step 2: Install Download Package
$ npm install download --save
Step 3: Update server.js file
server.js
const download = require('download')
// File URL
const url = `https://www.nicesnippets.com/image/nice-logo.png`
// Download the file
;(async () => {
await download(url, './')
})()
Run Node App
node serevr.js
I hope it can help you...
#Node JS