更新时间:2022-02-10 GMT+08:00
列举桶内对象
功能说明
列举桶内对象,默认返回最大1000个对象。
方法定义
func (obsClient ObsClient) ListObjects(input *ListObjectsInput) (output *ListObjectsOutput, err error)
使用带授权信息URL的方法定义
func (obsClient ObsClient) ListObjectsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListObjectsOutput, err error)
请求参数
|
参数名 |
类型 |
约束 |
|---|---|---|
|
input |
必选 |
返回结果
|
参数名 |
类型 |
|---|---|
|
output |
|
|
err |
error |
代码样例
func main() {
input := &obs.ListObjectsInput{}
input.Bucket = "bucketname"
output, err := obsClient.ListObjects(input)
if err == nil {
fmt.Printf("RequestId:%s\n", output.RequestId)
for index, val := range output.Contents {
fmt.Printf("Content[%d]-OwnerId:%s, ETag:%s, Key:%s, LastModified:%s, Size:%d\n",
index, val.Owner.ID, val.ETag, val.Key, val.LastModified, val.Size)
}
} else {
if obsError, ok := err.(obs.ObsError); ok {
fmt.Println(obsError.Code)
fmt.Println(obsError.Message)
} else {
fmt.Println(err)
}
}
}
父主题: 桶相关接口