How to use the httpreq.download function in httpreq

To help you get started, we’ve selected a few httpreq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ImyarekRu / Paradox / updater.js View on Github external
rawgithub(url, function(err, data){
    // => returns the file contents as a string
    if(err){console.log(err);console.log(url);process.exit(0);}
    console.log("Github ver:"+JSON.parse(data).app);
    console.log("Local ver:"+currentver.app);
    rimraf.sync(path.resolve(tmp_path,"./"+reponame));
    if(fs.existsSync(path.resolve(__dirname,"./update.zip")))    fs.unlinkSync(path.resolve(__dirname,  "./update.zip"));
    if(parseFloat(JSON.parse(data).app)==parseFloat(currentver.app)) {
		fs.writeFileSync(path.resolve(__dirname,"./update.track"),"updated");
		process.exit(0);
	}
    else
    {
		fs.writeFileSync(path.resolve(__dirname,"./update.track"),"downloading");
        httpreq.download(
            urlzip,
            path.resolve(__dirname,"./update.zip")
        , function (err, progress){
            if (err) return console.log(err);
			console.log(progress);
        }, function (err, res){
            if (err) return console.log(err);
            console.log(res);

            fs.createReadStream(path.resolve(__dirname + "/update.zip")).pipe(unzip.Extract({ path:tmp_path }))
            .on('finish', function () {
				console.log('chmoding...');
				try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_macx32'));}catch(err){;};
				try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x32'));}catch(err){;};
				try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x32.exe'));}catch(err){;};
				try{ fs.unlinkSync(path.resolve(tmp_path,"./"+reponame+'/node_x64'));}catch(err){;};
github megahertz / electron-simple-updater / lib / linux.js View on Github external
return new Promise((resolve, reject) => {
    request.download(url, tempPath, (err, progress) => {
      if (err) {
        return reject(err);
      }

      if (progress.statusCode !== 200) {
        return reject(progress.statusCode);
      }

      resolve(tempPath);
    });
  });
}

httpreq

node-httpreq is a node.js library to do HTTP(S) requests the easy way

MIT
Latest version published 7 months ago

Package Health Score

70 / 100
Full package analysis

Popular httpreq functions

Similar packages