blob

package
v0.3.0-beta0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobGCP

type BlobGCP struct {
	// contains filtered or unexported fields
}

BlobGCP is the GCP implementation of blob.BlobStore using Cloud Storage.

func NewBlobGCP

func NewBlobGCP(ctx context.Context, bucketURL string) (*BlobGCP, error)

NewBlobGCP returns a new BlobGCP instance.

func (*BlobGCP) Close

func (b *BlobGCP) Close() error

Close releases any resources used by the instance.

func (*BlobGCP) Delete

func (b *BlobGCP) Delete(ctx context.Context, path string) error

Delete deletes the blob at the given path.

func (*BlobGCP) Get

func (b *BlobGCP) Get(ctx context.Context, path string) ([]byte, error)

Get retrives the data given a blob path.

func (*BlobGCP) NewRangeReader

func (b *BlobGCP) NewRangeReader(ctx context.Context, path string, offset, length int64) (io.ReadCloser, error)

NewRangeReader returns an io.ReadCloser instance for the object specified by path, beginning at the offset-th byte and length bytes long. length = -1 means until EOF. Make sure to close the reader after all operations to the reader.

func (*BlobGCP) NewReader

func (b *BlobGCP) NewReader(ctx context.Context, path string) (io.ReadCloser, error)

NewReader is an alias to NewRangeReader(ctx, path, 0, -1), which creates a reader from the beginning of an object to EOF.

func (*BlobGCP) NewWriter

func (b *BlobGCP) NewWriter(ctx context.Context, path string) (io.WriteCloser, error)

NewWriter creates a new object with path and returns an io.WriteCloser instance for the object. The object is not committed and visible until you close the writer.

func (*BlobGCP) Put

func (b *BlobGCP) Put(ctx context.Context, path string, data []byte) error

Put inserts a blob at the given path.

func (*BlobGCP) SignUrl

func (b *BlobGCP) SignUrl(ctx context.Context, key string, ttlInSeconds int64, method string) (string, error)

SignUrl returns an open accessible signed url for the given blob key

type BlobStore

type BlobStore interface {
	Put(ctx context.Context, path string, data []byte) error

	// NewWriter creates a new object with path and returns an io.WriteCloser
	// instance for the object.
	// Make sure to close the writer after all operations to the writer.
	NewWriter(ctx context.Context, path string) (io.WriteCloser, error)
	Get(ctx context.Context, path string) ([]byte, error)

	// NewReader is an alias to NewRangeReader(ctx, path, 0, -1), which creates
	// a reader from the beginning of an object to EOF.
	NewReader(ctx context.Context, path string) (io.ReadCloser, error)

	// NewRangeReader returns an io.ReadCloser instance for the object specified by path,
	// beginning at the offset-th byte and length bytes long. length = -1 means until EOF.
	// Make sure to close the reader after all operations to the reader.
	NewRangeReader(ctx context.Context, path string, offset, length int64) (io.ReadCloser, error)
	Delete(ctx context.Context, path string) error

	SignUrl(ctx context.Context, key string, ttlInSeconds int64, method string) (string, error)
}

BlobStore is a public interface for Blob operations within Open Saves. Use one of the structs defined in the package. Currently available drivers: - BlobGCP: Google Cloud Storage

Jump to

Keyboard shortcuts

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