更新时间:2021-03-18 GMT+08:00
判断桶是否存在
功能说明
判断桶是否存在,如果返回的结果中HTTP状态码为200则表明桶存在,如果返回404则表明桶不存在。
方法定义
ObsClient.headBucket
请求参数
| 字段名 | 类型 | 约束 | 说明 |
|---|---|---|---|
| Bucket | String | 必选 | 桶名。 |
| RequestDate | String 或 Date | 可选 | 指定请求时间。 说明: 当为String类型时,必须符合ISO8601或RFC822规范。 |
返回结果(InterfaceResult)
| 字段名 | 类型 | 说明 |
|---|---|---|
| RequestId | String | OBS服务端返回的请求ID。 |
代码样例
obsClient.headBucket({
Bucket : 'bucketname'
}, function (err, result) {
if(err){
console.error('Error-->' + err);
}else{
if(result.CommonMsg.Status < 300){
console.log('Bucket exists');
}else if(result.CommonMsg.Status === 404){
console.log('Bucket does not exist');
}
}
}); 父主题: 桶相关接口