Skip to content

Commit

Permalink
feat: added acl to config
Browse files Browse the repository at this point in the history
Allows changing of the object ACL using either an environment variable or config option
  • Loading branch information
Sam Collins authored and colinmeinke committed Nov 19, 2018
1 parent 164c6aa commit 86a4886
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cp -r ./node_modules/ghost-storage-adapter-s3 ./content/adapters/storage/s3
"endpoint": "YOUR_OPTIONAL_ENDPOINT_URL (only needed for 3rd party S3 providers)",
"serverSideEncryption": "YOUR_OPTIONAL_SSE (See note 2 below)",
"forcePathStyle": true,
"acl": "YOUR_OPTIONAL_ACL (See note 4 below)",
}
}
```
Expand All @@ -37,6 +38,8 @@ Note 2: if your s3 bucket enforces SSE use serverSideEncryption with the [approp

Note 3: if your s3 providers requires path style you can enable it with `forcePathStyle`

Note 4: if you use CloudFront the object ACL does not need to be set to "public-read"

### Via environment variables

```
Expand All @@ -49,6 +52,7 @@ GHOST_STORAGE_ADAPTER_S3_PATH_PREFIX // optional
GHOST_STORAGE_ADAPTER_S3_ENDPOINT // optional
GHOST_STORAGE_ADAPTER_S3_SSE // optional
GHOST_STORAGE_ADAPTER_S3_FORCE_PATH_STYLE // optional
GHOST_STORAGE_ADAPTER_S3_ACL // optional
```

## AWS Configuration
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class Store extends BaseStore {
secretAccessKey,
endpoint,
serverSideEncryption,
forcePathStyle
forcePathStyle,
acl
} = config

// Compatible with the aws-sdk's default environment variables
Expand All @@ -36,6 +37,7 @@ class Store extends BaseStore {
this.endpoint = process.env.GHOST_STORAGE_ADAPTER_S3_ENDPOINT || endpoint || ''
this.serverSideEncryption = process.env.GHOST_STORAGE_ADAPTER_S3_SSE || serverSideEncryption || ''
this.s3ForcePathStyle = Boolean(process.env.GHOST_STORAGE_ADAPTER_S3_FORCE_PATH_STYLE) || Boolean(forcePathStyle) || false
this.acl = process.env.GHOST_STORAGE_ADAPTER_S3_ACL || acl || 'public-read'
}

delete (fileName, targetDir) {
Expand Down Expand Up @@ -87,7 +89,7 @@ class Store extends BaseStore {
readFileAsync(image.path)
]).then(([ fileName, file ]) => {
let config = {
ACL: 'public-read',
ACL: this.acl,
Body: file,
Bucket: this.bucket,
CacheControl: `max-age=${30 * 24 * 60 * 60}`,
Expand Down

0 comments on commit 86a4886

Please sign in to comment.