Skip to content

Commit 231d9c6

Browse files
committed
Add ability to configure ACL permissions
Right now, permissions are hard-coded to 'public-read'. This change adds a new prop to DropzoneS3Uploader called aclPermissions. The value is a string. Any canned aws ACL should be valid, we are using 'private' for our purposes. http://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl. Also, we are specifying the directory for babel in our build commands.
1 parent 3f55cac commit 231d9c6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-dropzone-s3-uploader",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Drag and drop s3 file uploader via react-dropzone + react-s3-uploader",
55
"main": "lib/index.js",
66
"author": {
@@ -13,9 +13,9 @@
1313
"url": "https://github.com/founderlab/react-dropzone-s3-uploader"
1414
},
1515
"scripts": {
16-
"prepublish": "rm -rf ./lib && babel ./src --ignore '/node_modules/' --out-dir ./lib",
17-
"build": "rm -rf ./lib && babel ./src --ignore '/node_modules/' --out-dir ./lib",
18-
"watch": "rm -rf ./lib && babel ./src --ignore '/node_modules/' --watch --out-dir ./lib",
16+
"prepublish": "rm -rf ./lib && ./node_modules/babel/bin/babel.js ./src --ignore '/node_modules/' --out-dir ./lib",
17+
"build": "rm -rf ./lib && ./node_modules/babel/bin/babel.js ./src --ignore '/node_modules/' --out-dir ./lib",
18+
"watch": "rm -rf ./lib && ./node_modules/babel/bin/babel.js ./src --ignore '/node_modules/' --watch --out-dir ./lib",
1919
"test": "eval $(cat test/.env) mocha test/**/*.tests.js"
2020
},
2121
"dependencies": {

src/DropzoneS3Uploader.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ export default class DropzoneS3Uploader extends React.Component {
1111
notDropzoneProps: PropTypes.array.isRequired,
1212
isImage: PropTypes.func.isRequired,
1313
passChildrenProps: PropTypes.bool,
14+
aclPermissions: PropTypes.oneOf([
15+
'private',
16+
'public-read',
17+
'public-read-write',
18+
'aws-exec-read',
19+
'authenticated-read',
20+
'bucket-owner-read',
21+
'bucket-owner-full-control',
22+
'log-delivery-write',
23+
]),
1424

1525
imageComponent: PropTypes.func,
1626
fileComponent: PropTypes.func,
@@ -42,6 +52,7 @@ export default class DropzoneS3Uploader extends React.Component {
4252

4353
static defaultProps = {
4454
upload: {},
55+
aclPermissions: 'public-read',
4556
className: 'react-dropzone-s3-uploader',
4657
passChildrenProps: true,
4758
isImage: filename => filename && filename.match(/\.(jpeg|jpg|gif|png|svg)/i),
@@ -89,7 +100,7 @@ export default class DropzoneS3Uploader extends React.Component {
89100
signingUrl: '/s3/sign',
90101
s3path: '',
91102
contentDisposition: 'auto',
92-
uploadRequestHeaders: {'x-amz-acl': 'public-read'},
103+
uploadRequestHeaders: {'x-amz-acl': props.aclPermissions },
93104
onFinishS3Put: this.handleFinish,
94105
onProgress: this.handleProgress,
95106
onError: this.handleError,

0 commit comments

Comments
 (0)