gcsuploader

package
v0.0.0-...-a9e01a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, httpClient *http.Client) (*clientImpl, error)

Types

type DryRunImpl

type DryRunImpl struct{}

DryRunImpl implements the GCSUploader and ImageDownloader interfaces (but doesn't actually upload or download anything)

func (*DryRunImpl) UploadBytes

func (h *DryRunImpl) UploadBytes(_ context.Context, _ []byte, fallbackSrc, dst string) error

UploadBytes implements the GCSUploader interface.

func (*DryRunImpl) UploadJSON

func (h *DryRunImpl) UploadJSON(_ context.Context, _ interface{}, tempFileName, gcsObjectPath string) error

UploadJSON implements the GCSUploader interface.

type GCSUploader

type GCSUploader interface {
	// UploadBytes copies a local file to GCS. If data is provided, those
	// bytes may be used instead of read again from disk.
	// The dst string is assumed to have a gs:// prefix.
	// Currently only uploading from a local file to GCS is supported, that is
	// one cannot use gs://foo/bar as 'fileName'
	UploadBytes(ctx context.Context, data []byte, fallbackSrc, dst string) error

	// UploadJSON serializes the given data to JSON and uploads the result to GCS.
	// An implementation can use tempFileName for temporary storage of JSON data.
	UploadJSON(ctx context.Context, data interface{}, tempFileName, gcsObjectPath string) error
}

GCSUploader implementations provide functions to upload to GCS.

type GsutilImpl

type GsutilImpl struct{}

GsutilImpl implements the GCSUploader and ImageDownloader interfaces.

func (*GsutilImpl) UploadBytes

func (g *GsutilImpl) UploadBytes(ctx context.Context, _ []byte, fallbackSrc, dst string) error

UploadBytes shells out to gsutil to copy the given src to the given target. A path starting with "gs://" is assumed to be in GCS.

func (*GsutilImpl) UploadJSON

func (g *GsutilImpl) UploadJSON(ctx context.Context, data interface{}, tempFileName, gcsObjPath string) error

UploadJSON serializes the given data to JSON and writes the result to the given tempFileName, then it copies the file to the given path in GCS. gcsObjPath is assumed to have the form: <bucket_name>/path/to/object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL