Proof-of-concept to download a file from a URL and save it locally. For example, I may wish to retrieve a JAR file from Nexus.
Uses the http
package, which does the basics with raw HTTP protocol support.
Possible update: use request
, it is like the Python's requests library. There is a companion package called node-request-progress
that tracks download progress. See request-progress on GitHub.
Note: The request package has been deprecated.
const http = require('http');
const fs = require('fs');
const file = fs.createWriteStream("file.jpg");
const request = http.get("http://i3.ytimg.com/vi/J---aiyznGQ/mqdefault.jpg", function(response) {
response.pipe(file);
});
This won't support https. should be something like this: