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

Environment variables and ACL fixes #7

Open
wants to merge 2 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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ When replacing the `GridFSStore` constructor with the `S3Store` one, make sure t
```javascript
new S3Store({
name, // Should be provided within buildGFS
isPublic: true,
objectACL: "public-read",
objectACL: "public-read", // You may not pass this property if you wish to do so
async transformWrite(fileRecord) {
// Either write your custom transformation code here, or re-use the one from the GridFSStore constructor
}
Expand Down
12 changes: 11 additions & 1 deletion src/S3Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export default class S3Store extends StorageAdapter {
s3Params.s3ForcePathStyle = true;
}

if (process.env.AWS_ACCESS_KEY_ID) {
debug("AWS_ACCESS_KEY_ID:", process.env.AWS_ACCESS_KEY_ID)
s3Params.accessKeyId = process.env.AWS_ACCESS_KEY_ID;
}

if (process.env.AWS_SECRET_ACCESS_KEY) {
debug("AWS_SECRET_ACCESS_KEY:", process.env.AWS_SECRET_ACCESS_KEY)
s3Params.secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
}

this.s3 = new S3({
apiVersion: "2006-03-01",
...s3Params
Expand Down Expand Up @@ -121,7 +131,7 @@ export default class S3Store extends StorageAdapter {

const uploadData = await this.s3.createMultipartUpload({
...opts,
ACL: this.objectACL
...(this.objectACL ? { ACL: this.objectACL } : {})
}).promise();

debug("s3.createMultipartUpload data:", uploadData);
Expand Down