I want to download a gzip file using Unirest library.I could download the zip file.when I opened the zip file to extract.It throws the error like this An error occurred while loading the archive.I thought that file didn't write properly.I tried the compression code.It is working fine but I won't compression a file because it might lose some data so I want exact file size.I could see the file size difference between directly download the zip file from that URL and compressed the file using node js.
unirest.get("http://ftp.gnu.org/gnu/wget/wget-1.5.3.tar.gz").end(function (file_reponse){
var stream = fs.createWriteStream("wget-1.5.3.tar.gz");
stream.once('open', function(fd) {
stream.write(file_reponse.raw_body);
stream.end();
});
});
via Karthick
No comments:
Post a Comment