how to download file from link in node js

Viewed 19

Is there a way to download video file from external cloud link to local system in node JS. I have currently v14.18.3 node JS in my app.

I wanted to let user download a video from Download button click. Please suggest any solutions.

I tried using below code but it is failing with error: Module not found: Can't resolve 'http' in

import * as Https from 'http';      
const file = fs.createWriteStream('file.mp4');
const request = Https.get('<cloud_link_of_file>', function(response) {
response.pipe(file);
 file.on('finish', () => {
  file.close();             
  console.log('Download Completed');
 });
});
0 Answers
Related