From 5f156b42b634d57bd7d0dc835d738401b908bcf2 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sat, 17 Feb 2018 11:21:58 +0100 Subject: add Container.Objects(), type ObjectIterator --- container.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'container.go') diff --git a/container.go b/container.go index f075d15..1e30eff 100644 --- a/container.go +++ b/container.go @@ -175,3 +175,25 @@ func (c *Container) EnsureExists() (*Container, error) { }.Do(c.a.client) return c, err } + +//Objects returns an ObjectIterator that lists the objects in this +//container. The most common use case is: +// +// objects, err := container.Objects().Collect() +// +//You can extend this by configuring the iterator before collecting the results: +// +// iter := container.Objects() +// iter.Prefix = "test-" +// objects, err := iter.Collect() +// +//Or you can use a different iteration method: +// +// err := container.Objects().ForeachDetailed(func (info ObjectInfo) error { +// log.Printf("object %s is %d bytes large!\n", +// info.Object.Name(), info.SizeBytes) +// }) +// +func (c *Container) Objects() *ObjectIterator { + return &ObjectIterator{Container: c} +} -- cgit v1.2.3