Most Popular Tutorials
Most Popular Tutorials :-

Simply Easy Learning at Your Fingertips. Click Tutorials Menu to view More Tutorial List





How to Downloading File REST API in node.js?

Install ExpressJs Modules

File Name :

npm install express --save

Create Server.js File

File Name : server.js

const express = require('express');
const app = express();
const path = require('path');

//route to download a file
app.get('/download/:file(*)',(req, res) => {
var file = req.params.file;
var fileLocation = path.join('./uploads',file);
console.log(fileLocation);
res.download(fileLocation, file);
});

Run App

File Name :

node server.js

Rest Api File Download Test using Postman

File Name :

API URL :- http://localhost:3000/download/your-file-name
Method :- GET





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here