获取桶元数据
更新时间: 2019-03-14 10:05
您可以通过ObsClient.GetBucketMetadata接口获取桶元数据。以下代码展示如何获取桶元数据:
- // 引入依赖包
- import (
- "fmt"
- "obs"
- )
- var ak = "*** Provide your Access Key ***"
- var sk = "*** Provide your Secret Key ***"
- var endpoint = "https://your-endpoint"
- // 创建ObsClient结构体
- var obsClient, _ = obs.New(ak, sk, endpoint)
- func main() {
- input := &obs.GetBucketMetadataInput{}
- input.Bucket = "bucketname"
- output, err := obsClient.GetBucketMetadata(input)
- if err == nil {
- fmt.Printf("RequestId:%s\n", output.RequestId)
- fmt.Printf("StorageClass:%s\n", output.StorageClass)
- } else if obsError, ok := err.(obs.ObsError); ok {
- fmt.Printf("StatusCode:%d\n", obsError.StatusCode)
- }
- }
父主题:管理桶