Skip to content

Commit

Permalink
Merge pull request #91 from lytics/add-context
Browse files Browse the repository at this point in the history
Add option to pass in context to getobject
  • Loading branch information
ajroetker authored Jun 3, 2021
2 parents 02decdf + c2a4d93 commit 1d4d62f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion google/storeutils/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1d4d62f

Please sign in to comment.