Listing Versioned Objects in a Bucket
API Description
You can use this API to list versioning objects in a bucket. By default, a maximum of 1000 versioning objects are listed.
Method Definition
func (obsClient ObsClient) ListVersions(input *ListVersionsInput) (output *ListVersionsOutput, err error)
Method Definition If a Signed URL Is Used
func (obsClient ObsClient) ListVersionsWithSignedUrl(signedUrl string, actualSignedRequestHeaders http.Header) (output *ListVersionsOutput, err error)
Request Parameter
| Field | Type | Optional or Mandatory |
|---|---|---|
| input | Mandatory |
Returned Result
| Field | Type |
|---|---|
| output | |
| err | error |
Sample Code
func main() { input := &obs.ListVersionsInput{} input.Bucket = "bucketname" input.MaxKeys = 100 output, err := obsClient.ListVersions(input) if err == nil { fmt.Printf("RequestId:%s\n", output.RequestId) for index, val := range output.Versions { fmt.Printf("Version[%d]-OwnerId:%s, ETag:%s, Key:%s, VersionId:%s, LastModified:%s, Size:%d\n", index, val.Owner.ID, val.ETag, val.Key, val.VersionId, val.LastModified, val.Size) } for index, val := range output.DeleteMarkers { fmt.Printf("DeleteMarker[%d]-OwnerId:%s, Key:%s, VersionId:%s, LastModified:%s\n", index, val.Owner.ID, val.Key, val.VersionId, val.LastModified) } } else { if obsError, ok := err.(obs.ObsError); ok { fmt.Println(obsError.Code) fmt.Println(obsError.Message) } else { fmt.Println(err) } } }
Last Article: Listing Objects in a Bucket
Next Article: Obtaining Bucket Metadata
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.