Skip to content

Commit

Permalink
fix(oss): fix error of setBucketPolicy api;
Browse files Browse the repository at this point in the history
  • Loading branch information
walle233 committed Apr 14, 2022
1 parent 214a2cd commit bee61bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions packages/system-server/http/oss.http
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ Authorization: Bearer {{token}}

{
"bucket": "test-for-create-bucket",
"mode": "private"
}


### Set bucket policy

PUT {{base_url}}/sys-api/apps/{{appid}}/oss/buckets/test-for-create-bucket
Authorization: Bearer {{token}}
Content-Type: application/json

{
"mode": "public-read"
}



### Delete a bucket

DELETE {{base_url}}/sys-api/apps/{{appid}}/oss/buckets/test-for-create-bucket
Expand Down
2 changes: 1 addition & 1 deletion packages/system-server/src/router/oss/delete-bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function handleDeleteBucket(req: Request, res: Response) {
const internalName = `${app.appid}-${bucketName}`
const ret = await oss.deleteBucket(internalName)
if (ret?.$metadata?.httpStatusCode !== 204) {
return res.send(ret?.$metadata)
return res.send({ code: 'ERROR', data: ret?.$metadata})
}

// delete bucket from app
Expand Down
4 changes: 2 additions & 2 deletions packages/system-server/src/router/oss/update-bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export async function handleSetBucketPolicy(req: Request, res: Response) {
const oss = await MinioAgent.New()
const internalName = `${app.appid}-${bucketName}`
const ret = await oss.setBucketACL(internalName, mode)
if (ret?.$metadata?.httpStatusCode !== 200) {
return res.send(ret?.$metadata)
if (ret?.$metadata?.httpStatusCode !== 204) {
return res.send({ code: 'ERROR', data: ret?.$metadata})
}

// update bucket to app
Expand Down

0 comments on commit bee61bd

Please sign in to comment.