I'm trying to figure out how to use a download link to download a file in node.js. When I enter in the following link (Download Subtitles for the Godfather) into my web browser it will automatically download the file that contains the subtitles. How do I do this in node? And is there a way to name the file as I want it to be named as well as choose it's path? Thank you in advance!
Asked
Active
Viewed 1,263 times
1 Answers
0
var http = require('http');
var fs = require('fs');
var file = fs.createWriteStream("file.jpg");
var request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
response.pipe(file);
});

Community
- 1
- 1

MoeSattler
- 6,684
- 6
- 24
- 44
-
Thank you! And thanks for linking me to where it had already been answered! – pbie42 Dec 08 '16 at 13:52