OBS Node.js SDK
OBS Node.js SDK
本文导读
链接复制成功!
获取桶元数据
功能说明
对桶发送HEAD请求,获取桶的存储类型,CORS规则(若已设置)等信息。
方法定义
ObsClient.getBucketMetadata
请求参数
字段名 |
类型 |
约束 |
说明 |
---|---|---|---|
Bucket |
String |
必选 |
桶名。 |
Origin |
String |
可选 |
预请求指定的跨域请求Origin(通常为域名)。 |
RequestHeader |
String |
可选 |
跨域请求可以使用的HTTP头域。 |
返回结果(InterfaceResult)
字段名 |
类型 |
说明 |
---|---|---|
RequestId |
String |
OBS服务端返回的请求ID。 |
StorageClass |
String |
桶的存储类型,当桶存储类型是标准存储时,该值为空。 |
Location |
String |
桶区域位置。 |
ObsVersion |
String |
OBS服务端版本。 |
AllowOrigin |
String |
如果请求中的Origin满足服务端的CORS规则,则返回服务端CORS配置中的AllowedOrigin。 |
AllowHeader |
String |
如果请求的RequestHeader满足服务端的CORS规则,则返回服务端CORS配置中的AllowedHeader。 |
AllowMethod |
String |
服务端CORS规则中的AllowedMethod。 |
ExposeHeader |
String |
服务端CORS规则中的ExposeHeader。 |
MaxAgeSeconds |
String |
服务端CORS规则中的MaxAgeSeconds。 |
代码样例
obsClient.getBucketMetadata({
Bucket : 'bucketname',
Origin : 'http://www.a.com',
RequestHeader : 'x-obs-header'
},(err, result) => {
if(err){
console.error('Error-->' + err);
}else{
if(result.CommonMsg.Status < 300){
console.log('RequestId-->' + result.InterfaceResult.RequestId);
console.log('StorageClass-->' + result.InterfaceResult.StorageClass);
console.log('Location-->' + result.InterfaceResult.Location);
console.log('AllowOrigin-->' + result.InterfaceResult.AllowOrigin);
console.log('AllowHeaders-->' + result.InterfaceResult.AllowHeader);
console.log('AllowMethods-->' + result.InterfaceResult.AllowMethod);
console.log('MaxAgeSeconds-->' + result.InterfaceResult.MaxAgeSeconds);
console.log('ExposeHeaders-->' + result.InterfaceResult.ExposeHeader);
}else{
console.log('Status-->' + result.CommonMsg.Status);
}
}
});
父主题: 桶相关接口