New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

curldownloader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curldownloader - npm Package Compare versions

Comparing version 0.0.3 to 0.0.5

8

example.js

@@ -13,4 +13,4 @@ // Code forked from: rabc/node-downloader

download.setDirToSave('~/Desktop/abc/123/456/789/qrst/');
download.downloadFile('https://dvtools.com/fmi/xml/cnt/data.cnt?-db=Dv_DataBase_2008_1v3%20Recovered&-lay=QtLi%20Simple%20Draw%20A&-recid=33572&-field=Li_CreatedIn_AiPsd_Graphic(1)', 'file.ai');
download.setDirToSave('~/');
download.downloadFile('http://127.0.0.1:8124/http://ipv4.download.thinkbroadband.com/10MB.zip', '10MB.zip');
// Alternatively download.downloadFile(req.url.substr(1), 'filename.zip');

@@ -22,2 +22,6 @@

download.eventEmitter.on('error', function(err) {
console.log('Error Occured:', err);
});
download.eventEmitter.on('end', function(code) {

@@ -24,0 +28,0 @@ if (code == 0) {

var spawn = require('child_process').spawn,
events = require('events');
events = require('events');
function CurlDownloader() {
var dirToSave = './';

@@ -9,13 +9,23 @@ var dl;

var lastProgress = 0;
var authVal
var authType
var eventEmitter = new events.EventEmitter();
this.setAuthType = function(type) {
authType = type
}
this.setPrivateToken = function(token) {
authVal = '-H' + authType + ':' + token
}
this.setDirToSave = function(dir) {
dirToSave = dir;
}
this.getDirToSave = function() {
return dirToSave;
}
this.downloadFile = function(url, file) {

@@ -25,3 +35,3 @@ console.log('Beginning Download from: ' + url + ' Saving to: ' + dirToSave);

if (typeof file == 'undefined') {
var file = url.substring(url.lastIndexOf('/')+1);
var file = url.substring(url.lastIndexOf('/') + 1);
}

@@ -31,18 +41,22 @@

file = file.replace(/[^0-9a-zA-Z\.]+/gi, '');
var path = dirToSave+file;
dlOptions = [url, '--create-dirs', '-o' + path, '-#', '--insecure'];
var path = dirToSave + file;
dlOptions = [
authVal, url, '--create-dirs', '-o' + path,
'-#',
'--insecure'
];
dl = spawn('curl', dlOptions);
dl.on('exit', function (code) {
dl.on('exit', function(code) {
// Important for multiple downloads to know when they are finished.
eventEmitter.emit('end', code);
});
dl.stderr.on('data', function (data) {
dl.stderr.on('data', function(data) {
data = data.toString('ascii');
// Extract the progress percentage

@@ -55,7 +69,7 @@ if (/\d+(\.\d{1,2})/.test(data)) {

lastProgress = progress;
eventEmitter.emit('progress', progress + '%');
}
}
});

@@ -65,3 +79,3 @@

}
this.stopDownload = function() {

@@ -71,5 +85,7 @@ console.log('Download stopped');

}
// Expose the public API
return {
setPrivateToken: this.setPrivateToken,
setAuthType: this.setAuthType,
setDirToSave: this.setDirToSave,

@@ -76,0 +92,0 @@ getDirToSave: this.getDirToSave,

@@ -5,3 +5,3 @@ {

"tags": ["downloader","download","curl"],
"version": "0.0.3",
"version": "0.0.5",
"author": "Aaron Ogle <aaron@geekgonecrazy.com>",

@@ -8,0 +8,0 @@ "repository": {

@@ -15,3 +15,3 @@ # Node.js Curl Downloader

* Download [node_download.js](node_download.js)
* Download [node_download.js](lib/node_download.js)
* Include in project

@@ -18,0 +18,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc