Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump dependencies #5

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ Example Usage

s3Sizer.getFolderSize('bucket.name', 'foldername', function(err, size) {
console.log(size)
});
});
If you already have s3 instance, you can pass it in parameter:

var s3 = new AWS.S3();
s3Sizer = new S3Sizer({"s3": s3});
28 changes: 16 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,25 @@ var AWS = require('aws-sdk');
* accessKeyId is included then secretAccessKey must also be included.
* @config {string} [params.region] The AWS region to make calls against.
*/
var S3Sizer = function(params) {
if(params.hasOwnProperty('configFile')) {
AWS.config.loadFromPath(params.configFile);
}
var S3Sizer = function(params) {
if(params.hasOwnProperty('s3')) {
this.s3 = params.s3;
} else{
if(params.hasOwnProperty('configFile')) {
AWS.config.loadFromPath(params.configFile);
}

if(params.hasOwnProperty('accessKeyId') && params.hasOwnProperty('secretAccessKey')) {
AWS.config.update({accessKeyId : params.accessKeyId, secretAccessKey : params.secretAccessKey});
}
if(params.hasOwnProperty('accessKeyId') && params.hasOwnProperty('secretAccessKey')) {
AWS.config.update({accessKeyId : params.accessKeyId, secretAccessKey : params.secretAccessKey});
}

if(params.hasOwnProperty('region')) {
AWS.config.update({region : params.region});
}
if(params.hasOwnProperty('region')) {
AWS.config.update({region : params.region});
}

this.s3 = new AWS.S3();
};
this.s3 = new AWS.S3();
}
};

/**
* Gets the combined file size of all the objects in a S3 folder.
Expand Down
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"name": "aws-s3-size",
"version": "0.0.2",
"version": "0.2.1",
"description": "Simple module to calculate folder size in S3.",
"main": "index.js",
"author": "Modulus <[email protected]>",
"maintainers": [
"zwigby <[email protected]>"
"Charlie Key <[email protected]>",
"Brandon Cannaday <[email protected]>"

],
"repository": "",
"dependencies": {
"aws-sdk" : "*"
"aws-sdk" : "2.1179.0"
},
"repository": {
"type": "git",
"url": "https://github.com/onmodulus/aws-s3-size"
},
"devDependencies" : {
"mocha" : "1.7.x",
"expect.js" : "0.2.x"
"mocha" : "10.0.x",
"expect.js" : "0.3.x"
},
"keywords": [
"aws",
Expand Down
12 changes: 2 additions & 10 deletions test/test-s3-size.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var S3Sizer = require('../index');
configFile = __dirname + '/awscreds.json',
configFile = __dirname + '/testcreds.json',
s3Sizer = new S3Sizer({configFile : configFile}),
expect = require('expect.js'),
fs = require('fs'),
Expand All @@ -11,15 +11,7 @@ describe('S3 Sizer Module', function() {
// get test storage size
s3Sizer.getFolderSize(config.bucket, config.folder, function(err, size) {
expect(err).to.not.be.ok();
expect(size).to.be(1354482);
done();
});
});
it('should return the 0 is there are no items in folder', function(done) {
// get test storage size
s3Sizer.getFolderSize(config.bucket, config.zeroFolder, function(err, size) {
expect(err).to.not.be.ok();
expect(size).to.be(0);
expect(size).to.be.greaterThan(0);
done();
});
});
Expand Down