diff --git a/cli/service/service.go b/cli/service/service.go index 860b08a..f1056db 100644 --- a/cli/service/service.go +++ b/cli/service/service.go @@ -371,7 +371,12 @@ func (s *service) createObject(ctx context.Context, namespaceName, containerName "url": url, }).Info("uploading BLOB ...") - if err := uploadBlob(ctx, url, object.Contents, object.Size); err != nil { + rd, err := object.Contents(ctx) + if err != nil { + return err + } + + if err := uploadBlob(ctx, url, rd, object.Size); err != nil { return err } } diff --git a/cli/service/source/local/local.go b/cli/service/source/local/local.go index 7883aa8..b15ce2b 100644 --- a/cli/service/source/local/local.go +++ b/cli/service/source/local/local.go @@ -114,8 +114,10 @@ func (l *local) Process(ctx context.Context, handler func(ctx context.Context, o defer fp.Close() if err := handler(ctx, source.Object{ - Path: shortPath, - Contents: fp, + Path: shortPath, + Contents: func(ctx context.Context) (io.Reader, error) { + return fp, nil + }, SHA256: checksum, Size: uint64(size), MimeType: mimeType, diff --git a/cli/service/source/source.go b/cli/service/source/source.go index 2186a95..b199a08 100644 --- a/cli/service/source/source.go +++ b/cli/service/source/source.go @@ -7,7 +7,7 @@ import ( type Object struct { Path string - Contents io.Reader + Contents func(ctx context.Context) (io.Reader, error) SHA256 string Size uint64 MimeType string diff --git a/cli/service/source/yum/yum.go b/cli/service/source/yum/yum.go index c3e5fdd..b57042f 100644 --- a/cli/service/source/yum/yum.go +++ b/cli/service/source/yum/yum.go @@ -92,8 +92,10 @@ func (r *repository) Process(ctx context.Context, handler func(ctx context.Conte log.Tracef("handler(%s, %s, %d)", k, checksum, size) if err := handler(ctx, source.Object{ - Path: k, - Contents: bytes.NewReader(v), + Path: k, + Contents: func(ctx context.Context) (io.Reader, error) { + return bytes.NewReader(v), nil + }, SHA256: checksum, Size: uint64(size), MimeType: mimeType, @@ -160,14 +162,9 @@ func (r *repository) Process(ctx context.Context, handler func(ctx context.Conte } mimeType := mimetype.Detect(data) - fp, err = lb.Reader(ctx) - if err != nil { - return errors.Wrap(err, "error getting object reader") - } - if err := handler(ctx, source.Object{ Path: name, - Contents: fp, + Contents: lb.Reader, SHA256: checksum, Size: size, MimeType: mimeType.String(),