GET Objects
API Description
You can use this API to list objects in a bucket. By default, a maximum of 1000 objects are listed.
Method Definition
func (obsClient ObsClient) ListObjects(input *ListObjectsInput) (output *ListObjectsOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) ListObjectsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListObjectsOutput, err error)
Request Parameter
|
Field |
Type |
Optional or Mandatory |
|---|---|---|
|
input |
Mandatory |
Returned Result
|
Field |
Type |
|---|---|
|
output |
|
|
err |
error |
Sample Code
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)
}
}
}
Last Article: DELETE Bucket
Next Article: GET Object versions
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.