node js download file to folder
var http = require('http');
var fs = require('fs');
var download = function(url, dest, cb) {
var file = fs.createWriteStream(dest);
var request = http.get(url, function(response) {
response.pipe(file);
file.on('finish', function() {
file.close(cb); // close() is async, call cb after close completes.
});
}).on('error', function(err) { // Handle errors
fs.unlink(dest); // Delete the file async. (But we don't check the result)
if (cb) cb(err.message);
});
};
Also in JavaScript:
- javascript write to text file
- ajax is not a function
- nodejs add to array
- if parameter is not number in js
- js scroll page horizontally with mouse wheel
- javascript get data-id attribute
- how to check chrome version in js
- moving letters animation javascript
- js alert and redirect
- check if form bootstrap is valid js
- async await react stackoverflow
- sass variables across files
- javascript touppercase
- require a json as a string
- remove header from certain pages react navigation
- javascript submit form when enter key pressed
- promise javascript
- how set defualt image for dropify
- update json in postgres
- how to loop code in javascript
- disable mixed content via javascript
- if isset handlebars js
- react native dropdown
- js remove item array