API | Operation | Description |
Checking a bucket and its permissions | Checks whether a bucket exists and whether you have permission to access it | |
Deleting a bucket | Deletes an empty bucket from a specified account |
cos.headBucket({Bucket: 'examplebucket-1250000000', /* Required */Region: 'COS_REGION', /* Bucket region. Required */}, function(err, data) {console.log(err || data);});
function doesBucketExist() {cos.headBucket({Bucket: 'examplebucket-1250000000', /* Required */Region: 'COS_REGION', /* Bucket region. Required */}, function(err, data) {if (data) {console.log('The bucket exists.');} else if (err.statusCode == 403) {console.log('no permission to read the bucket');}});}
Parameter | Description | Type | Required |
Bucket | Bucket name in the format of BucketName-APPID . | String | Yes |
Region | String | Yes |
function(err, data) { ... }
Parameter Name | Description | Type |
err | Error code, which is returned when an error (network error or service error) occurs. If the request is successful, this parameter is empty. For more information, please see Error Codes. | Object |
- statusCode | HTTP status code, such as 200, 403, and 404 | Number |
- headers | Headers | Object |
data | Content returned when the request is successful. If the request fails, this parameter is empty. | Object |
- statusCode | HTTP status code, such as 200, 403, and 404 | Number |
- headers | Headers | Object |
cos.deleteBucket({Bucket: 'examplebucket-1250000000', /* Required */Region: 'COS_REGION', /* Bucket region. Required */}, function(err, data) {console.log(err || data);});
Parameter | Description | Type | Required |
Bucket | Bucket name in the format of BucketName-APPID . | String | Yes |
Region | String | Yes |
function(err, data) { ... }
Parameter Name | Description | Type |
err | Object returned when an error (network error or service error) occurs. If the request is successful, this parameter is left empty. For more information, please see Error Codes. | Object |
- statusCode | HTTP status code, such as 200, 403, and 404 | Number |
- headers | Headers | Object |
data | Content returned when the request is successful. If the request fails, this parameter is empty. | Object |
- statusCode | HTTP status code, such as 200, 403, and 404 | Number |
- headers | Headers | Object |
Apakah halaman ini membantu?