Skip to content

Commit b99ff67

Browse files
committed
set bucket policy
1 parent cba5628 commit b99ff67

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

server/lib/minio.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,35 @@ import { minioConfig } from '../config'
33

44
const { client, region } = minioConfig
55

6+
const setBucketPolicy = async (bucketName) => {
7+
try {
8+
await client.setBucketPolicy(bucketName, JSON.stringify({
9+
Version: '2012-10-17',
10+
Statement: [
11+
{
12+
Sid: '',
13+
Action: ['s3:GetObject'],
14+
Effect: 'Allow',
15+
Resource: `arn:aws:s3:::${bucketName}/*`,
16+
Principal: {
17+
AWS: ['*']
18+
}
19+
}
20+
]
21+
}))
22+
} catch (err) {
23+
logger.error(err)
24+
}
25+
}
26+
627
/**
728
* Creates a bucket to upload
829
* @param {String} bucketName
930
*/
1031
const makeBucket = async (bucketName) => {
1132
try {
1233
await client.makeBucket(bucketName, region)
34+
await setBucketPolicy(bucketName)
1335
} catch (err) {
1436
logger.error(err)
1537
}

0 commit comments

Comments
 (0)