查询元数据索引

最近更新时间:2024-07-09 09:32:22

我的收藏

简介

本文档提供关于查询元数据索引的相关 API 概览以及 SDK 示例代码。
API
操作描述
查询元数据索引

查询元数据索引

功能说明

获取数据集内已完成索引的一个文件的元数据。

参数说明

请求参数,具体可查看 查询元数据索引 文档。

方法原型

func (s *MetaInsightService) DescribeFileMetaIndex(ctx context.Context, opt *undefined) (*DescribeFileMetaIndexResult, *Response, error)

请求示例

// 存储桶名称,由 bucketname-appid 组成,appid 必须填入,可以在 COS 控制台查看存储桶名称。 https://console.cloud.tencent.com/cos5/bucket
// 替换为用户的 region,存储桶 region 可以在 COS 控制台“存储桶概览”查看 https://console.cloud.tencent.com/ ,关于地域的详情见 https://cloud.tencent.com/document/product/436/6224 。
u, _ := url.Parse("https://test1-1250000000.cos.ap-beijing.myqcloud.com")
metaInsight, _ := url.Parse("https://1250000000.ci.ap-beijing.myqcloud.com")
b := &cos.BaseURL{BucketURL: u, MetaInsightURL: metaInsight}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
// 通过环境变量获取密钥
// 环境变量 SECRETID 表示用户的 SecretId,登录访问管理控制台查看密钥,https://console.cloud.tencent.com/cam/capi
SecretID: os.Getenv("SECRETID"),
SecretKey: os.Getenv("SECRETKEY"),
},
})

opt := &cos.DescribeFileMetaIndexOptions{
Datasetname: "notdelete",
Uri: "cos://0-c-1250000000/2022/",
}


res, _, err := c.MetaInsight.DescribeFileMetaIndex(context.Background(), opt)
if err != nil {
fmt.Println(err)
}
fmt.Println(res)

结果说明

调用 DescribeFileMetaIndex 函数,会解析 api 返回的 json 内容到 DescribeFileMetaIndexResult 结构,具体返回参数可查看 查询元数据索引 文档。