aboutsummaryrefslogtreecommitdiff
path: root/container.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-02-17 11:21:58 +0100
committerStefan Majewsky <majewsky@gmx.net>2018-02-17 11:21:58 +0100
commit5f156b42b634d57bd7d0dc835d738401b908bcf2 (patch)
treef6e657d4cdf53bd66c0660873d721c5e142b793a /container.go
parentf2bbc3ca2d83b8e0da3ff3652f9d721c6cd91955 (diff)
downloadgo-schwift-5f156b42b634d57bd7d0dc835d738401b908bcf2.tar.gz
add Container.Objects(), type ObjectIterator
Diffstat (limited to 'container.go')
-rw-r--r--container.go22
1 files changed, 22 insertions, 0 deletions
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}
+}