I have a feature on my program where in it downloads thousands of files to the server using using the url. Now i was told to hash the file before downloading it . Is that for Integrity check ? Is checksum a good solution ?, And also can anyone tell me what is the big use of using hashing algorithm on downloading files to a server. Is Hash value and Checksum a solution to that ? Would it lessen my cost on servers cause we know in product every "write" has a cost . Can anyone please explain to me the real use and purpose of hashing file before downloading it on the server. Thank you. How can we integrate that file hashing to my code below. Help would be much appreciated , thank you.
My code on downloading file to a server
final_list is an array of urls by the way
var download = function (url, dest, callback) {
request.get(url)
.on('error', function (err) { console.log(err) })
.pipe(fs.createWriteStream(dest))
.on('close', callback);
};
final_list.forEach(function (str) {
var filename = str.split('/').pop();
console.log('Downloading ' + filename);
download(str, filename, function () { console.log('Finished Downloading' + "" + filename) });
});