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

Add endpoint & s3PathStyle #52

Open
wants to merge 3 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
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ Either from the constructor or from the `init(config)` function you can pass alo
secretAccessKey: [your access key],
region: [the region of your S3 bucket],
bucket: [your bucket name],
endpoint: [optional, for use with S3-compatible services]
endpoint: [optional, for use with S3-compatible services],
s3ForcePathStyle: [optional, whether to force path style URLs for S3 objects]

}
```
If using temporary credentials
Expand All @@ -168,7 +170,8 @@ If using temporary credentials
sessionToken: [your session token],
region: [the region of your S3 bucket],
bucket: [your bucket name],
endpoint: [optional, for use with S3-compatible services]
endpoint: [optional, for use with S3-compatible services],
s3ForcePathStyle: [optional, whether to force path style URLs for S3 objects]
}
```
### `filterOutFiles(file)`
Expand Down
29 changes: 16 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ function S3Zipper(awsConfig) {
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.');

var configParams = {
accessKeyId: awsConfig.accessKeyId,
secretAccessKey: awsConfig.secretAccessKey,
region: awsConfig.region
};

if (awsConfig.sessionToken)
configParams.sessionToken = awsConfig.sessionToken;

if(awsConfig.sessionToken) {
AWS.config.update({
accessKeyId: awsConfig.accessKeyId,
secretAccessKey: awsConfig.secretAccessKey,
sessionToken: awsConfig.sessionToken,
region: awsConfig.region
}); }
else {
AWS.config.update({
accessKeyId: awsConfig.accessKeyId,
secretAccessKey: awsConfig.secretAccessKey,
region: awsConfig.region
}
if (awsConfig.endpoint)
configParams.endpoint = awsConfig.endpoint;

if (awsConfig.s3ForcePathStyle)
configParams.s3ForcePathStyle = awsConfig.s3ForcePathStyle;

AWS.config.update(configParams);

self.init(awsConfig);
}
Expand Down