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

nodejs-box

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodejs-box - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

42

lib/index.js

@@ -49,4 +49,16 @@ var VERSION = '0.0.1',

// Uploads a file to a given folder
Files.prototype.upload = function(filename, folder, callback){
// Utility method used to overload a method based on the number of arguments it has
// http://ejohn.org/blog/javascript-method-overloading/
function addMethod(object, name, fn){
var old = object[ name ];
object[ name ] = function(){
if ( fn.length == arguments.length )
return fn.apply( this, arguments );
else if ( typeof old == 'function' )
return old.apply( this, arguments );
};
}
// Uploads a file to a given folder... no custom filename
addMethod(Files.prototype, 'upload', function(filepath, folder, callback) {
request

@@ -56,3 +68,3 @@ .post(this.options.upload_url+'/'+this.resource+'/content')

.field('parent_id', folder)
.attach('filename', filename)
.attach('filename', filepath)
.end(function(res){

@@ -64,4 +76,26 @@ if(res.error)

});
};
});
// Uploads a file to a given folder a with custom filename
addMethod(Files.prototype, 'upload', function(filepath, filename, folder, callback) {
request
.post(this.options.upload_url+'/'+this.resource+'/content')
.set('Authorization', this.options.auth)
.field('attributes', JSON.stringify({
parent: {
id: folder
},
name: filename
}))
.attach('file', filepath)
.end(function(res){
if(res.error) {
return callback('Error: ' + res.error.message);
}
console.log(res);
callback(null, res.body);
});
});
// Retrieves a download link for the given file

@@ -68,0 +102,0 @@ Files.prototype.download = function(file, callback){

2

package.json
{
"name": "nodejs-box",
"version": "0.0.3",
"version": "0.0.4",
"description": "Box API client for Node.JS",

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

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