Skip to content

Commit 1d4d62f

Browse files
authored
Merge pull request #91 from lytics/add-context
Add option to pass in context to getobject
2 parents 02decdf + c2a4d93 commit 1d4d62f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

google/storeutils/get.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ import (
1212

1313
// GetObject Gets a single object's bytes based on bucket and name parameters
1414
func GetObject(gc *storage.Client, bucket, name string) (*bytes.Buffer, error) {
15+
return GetObjectWithContext(context.Background(), gc, bucket, name)
16+
}
1517

16-
rc, err := gc.Bucket(bucket).Object(name).NewReader(context.Background())
18+
// GetObject Gets a single object's bytes based on bucket and name parameters
19+
func GetObjectWithContext(ctx context.Context, gc *storage.Client, bucket, name string) (*bytes.Buffer, error) {
20+
rc, err := gc.Bucket(bucket).Object(name).NewReader(ctx)
1721
if err != nil {
1822
if err == storage.ErrObjectNotExist {
1923
return nil, cloudstorage.ErrObjectNotFound

0 commit comments

Comments
 (0)