Bucket permission management
Bucket permission control
Set bucket access permission
-
Basic workflow
- Create a BosClient instance.
- Run the setBucketAcl() method.
- Example code
js //Set the bucket access permission as private client.setBucketCannedAcl(<BucketName>, 'private') .then(function() { // Setup completed }) .catch(function(error) { // Setup failed });Request parameters for the setBucketCannedAclmethod:
| Parameters | Description |
|---|---|
| BucketName | Bucket name |
| CannedAcl | Bucket access permission |
Note
CannedACL contains three values:
private,public-readandpublic-read-write, which correspond to respective permissions. For details, refer to BOS API Documentation - [Permission Control Using CannedAcl](BOS/API Reference/Access control.md#Permission control by CannedAcl).
Set access permissions for a specific user on the bucket
-
Basic workflow
- Create a BosClient instance.
- Run the setBucketAcl() method.
-
Example code
JavaScript1let grant_list = [ 2 { 3 'grantee': [ 4 {'id': <UserID1>}, // Grant permission to specific user 1 5 {'id': <UserID2>}, // Grant permission to specific user 2 6 ], 7 'permission': ['FULL_CONTROL'] // Set permission to FULL_CONTROL 8 }, 9 { 10 'grantee': [ 11 {'id': <UserID3>}, // Grant permission to specific user 3 12 ], 13 'permission': ['READ'] // Set permission to READ 14 } 15]; 16client.setBucketAcl(<BucketName>, grant_list) 17 .then(function() { 18 // Setup completed 19 }) 20 .catch(function(error) { 21 // Setup failed 22 });Execute the request parameters for the setBucketAclmethod:
| Parameters | Description |
|---|---|
| BucketName | Bucket name |
| accessControlList | Permission list of the bucket |
| +grantee | List of user IDs for which permissions are set |
| +permission | Set permissions |
Note
The permission settings in Permission include three values:
READ,WRITE,FULL_CONTROL, which correspond to relevant permissions respectively. For details, refer to BOS API Documentation - [Permission Control via Uploading ACL Files](BOS/API Reference/Access control.md#Permission control by uploading ACL files).
Set STS temporary token permissions
For temporary access identities created through STS, administrators can also set specific permissions. For an introduction to STS and how to set temporary permissions, please refer to [Temporary Authorization Access](BOS/API Reference/Access control.md#Temporary authorized access).
For setting STS temporary token permissions using the BOS JavaScript SDK, you can refer to Accessing BOS via STS
View bucket permission
-
Basic workflow
- Create a BosClient instance.
- Run the getBucketAcl() method.
-
Example code
JavaScript1client.getBucketAcl(<BucketName>) 2 .then(function() { 3 // Setup completed 4 }) 5 .catch(function(error) { 6 // Setup failed 7 });
Parameters returned by executing the getBucketAcl method include:
| Parameters | Description |
|---|---|
| owner | Bucket owner information |
| +id | User ID of bucket owner |
| access_control_list | Identify the permission list of the bucket |
| +grantee | Identify the grantee |
| ++id | Authorized person ID |
| +permission | Identify the grantee permissions |
| +resource | Resources affected by ACL configuration items |
