A way how to download a file.
When you need a script for downloading a file by JavaScript.
Sends a request on a http server. When the response is with the status code 200 or 201, saves it.
There is no configuration needed.
##How to run? You can run the script from a code:
var curljs = require("curl-js");
curljs.curl(destination, source, function (err) {
if (err) {
return;
}
// do some stuff
});
- destination - path where to save the downloaded file
- source - URL address
- callback - function which is invoked when the file has been downloaded
If you have a problem, write me.
Sometimes you appreciate to have a file content in a string
var curljs = require("curl-js");
curljs.curlToString(destination, source, (function (err, content) {
if (err) {
return;
}
// do some stuff
});
- source - URL address
- callback - function which is invoked when the file has been downloaded