diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-08-12 15:57:38 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-08-12 15:10:06 +0000 |
| commit | 7b0f4b466c607f4d0fb87ca80c45a43dc937d122 (patch) | |
| tree | db8668ecf9ae7c932ceafe3a43b9bc8b9449cadd /pkg/gcs | |
| parent | 2235b7c2d4bfb5d187135362cf1f3f0e708972df (diff) | |
pkg/gcs: func ListObjects supports path
Diffstat (limited to 'pkg/gcs')
| -rw-r--r-- | pkg/gcs/gcs.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/pkg/gcs/gcs.go b/pkg/gcs/gcs.go index 756d2c65d..c9e62c86e 100644 --- a/pkg/gcs/gcs.go +++ b/pkg/gcs/gcs.go @@ -175,8 +175,14 @@ type Object struct { CreatedAt time.Time } -func (client *Client) ListObjects(bucket string) ([]*Object, error) { - it := client.client.Bucket(bucket).Objects(client.ctx, nil) +// ListObjects expects "bucket/path" or "bucket" as input. +func (client *Client) ListObjects(bucketObjectPath string) ([]*Object, error) { + bucket, objectPath, err := split(bucketObjectPath) + if err != nil { // no path specified + bucket = bucketObjectPath + } + query := &storage.Query{Prefix: objectPath} + it := client.client.Bucket(bucket).Objects(client.ctx, query) ret := []*Object{} for { objAttrs, err := it.Next() |
