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

type: feat #22

Open
wants to merge 5 commits into
base: master
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
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ var s3 = require('s3');
function S3Zipper(awsConfig) {
var self = this
assert.ok(awsConfig, 'AWS S3 options must be defined.');
assert.notEqual(awsConfig.accessKeyId, undefined, 'Requires S3 AWS Key.');
assert.notEqual(awsConfig.secretAccessKey, undefined, 'Requires S3 AWS Secret');
if (!awsConfig.useCredentials) {
assert.notEqual(awsConfig.accessKeyId, undefined, 'Requires S3 AWS Key.');
assert.notEqual(awsConfig.secretAccessKey, undefined, 'Requires S3 AWS Secret');
}
assert.notEqual(awsConfig.region, undefined, 'Requires AWS S3 region.');
assert.notEqual(awsConfig.bucket, undefined, 'Requires AWS S3 bucket.');

Expand Down Expand Up @@ -41,12 +43,10 @@ S3Zipper.prototype = {
, filterOutFiles: function (fileObj) {
return fileObj;
}
, calculateFileName: function (f) {
, calculateFileName: function (f, params) {
var name = f.Key.split("/");
name.shift();
name = name.join("/");
return name;

return !params.folderPath ? name[name.length-1] : name.join("/");
}

/*
Expand Down Expand Up @@ -184,7 +184,7 @@ S3Zipper.prototype = {
callback(err);
else {

var name = t.calculateFileName(f);
var name = t.calculateFileName(f, params);

if (name === ""){
callback(null, f);
Expand Down Expand Up @@ -270,6 +270,7 @@ S3Zipper.prototype = {
,s3ZipFileName:arguments[2]
,tmpDir:arguments[3]
,recursive: false
,folderPath: typeof params.folderPath == 'boolean' ? params.folderPath : true
};
callback= arguments[4];
}
Expand Down Expand Up @@ -399,6 +400,7 @@ S3Zipper.prototype = {
, startKey:arguments[1]
, zipFileName:arguments[2]
, recursive: false
, folderPath: params.folderPath
};
callback= arguments[3];
}
Expand Down
Loading