var ultUrls = [{
url: 'https://i.redd.it/kl44uq60z4631.png',
name: 'pics/A bison in steam during winter at Yellowstone National Park.png'
}, {
url: 'https://i.redd.it/9eocp20xr6631.jpg',
name: 'pics/Athens at night.jpg'
}, {
url: 'https://i.redd.it/0gezn9zjr6631.jpg',
name: 'pics/This is Rayne. Her favorite color is orange. Her job is a clown for the circus. Her motto is *honk honk*..jpg'
}, {
url: 'https://i.redd.it/fxcivargr6631.png',
name: 'pics/Reddit your input is greatly appreciated.png'
}, {
url: 'https://i.redd.it/xzpukskhr6631.jpg',
name: 'pics/Cranberry lake Ontario.jpg'
}, {
url: 'https://i.redd.it/4mplt3joh5631.jpg',
name: 'pics/Pics of insects are the best.jpg'
}, {
url: 'https://i.redd.it/03q4c5ndq6631.jpg',
name: 'pics/Elvis Presley during his service in the U.S. Army.jpg'
}]
While downloading files in this array I'm getting ENONENT:no such file or directory, open ...
var downloadImages = function(callback) {
ultUrls.forEach( function(str) {
download_file_httpget(str.url, str.name, function(){console.log('Finished Downloading' + filename)});
});
}
var download_file_httpget = function(url, dest, callback){
request.get(url)
.on('error', function(err) {console.log(err)} )
.pipe(fs.createWriteStream(dest))
.on('close', callback);
};
Tried with destination
var download_file_httpget = function(url, dest, callback){
let destn = 'C:\\Users\\Downloads\\' + dest;
request.get(url)
.on('error', function(err) {console.log(err)} )
.pipe(fs.createWriteStream(destn))
.on('close', callback);
};
UnCaught Exception: Error:ENONENT: no such file or directory, open 'C:\Users\Downloads\pics\A bison in steam during winter at Yellowstone National Park.png