From c2a4d936d4e06886a32ca0d68574125a0d3ac040 Mon Sep 17 00:00:00 2001 From: AJ Roetker Date: Thu, 3 Jun 2021 11:55:23 -0700 Subject: [PATCH] Add option to pass in context to getobject --- google/storeutils/get.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/google/storeutils/get.go b/google/storeutils/get.go index 16d9f8d..feff606 100644 --- a/google/storeutils/get.go +++ b/google/storeutils/get.go @@ -12,8 +12,12 @@ import ( // GetObject Gets a single object's bytes based on bucket and name parameters func GetObject(gc *storage.Client, bucket, name string) (*bytes.Buffer, error) { + return GetObjectWithContext(context.Background(), gc, bucket, name) +} - rc, err := gc.Bucket(bucket).Object(name).NewReader(context.Background()) +// GetObject Gets a single object's bytes based on bucket and name parameters +func GetObjectWithContext(ctx context.Context, gc *storage.Client, bucket, name string) (*bytes.Buffer, error) { + rc, err := gc.Bucket(bucket).Object(name).NewReader(ctx) if err != nil { if err == storage.ErrObjectNotExist { return nil, cloudstorage.ErrObjectNotFound