blob

package
v1.0.3-gitspaces-beta Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = errors.New("resource not found")
	ErrNotSupported = errors.New("not supported")
)
View Source
var WireSet = wire.NewSet(
	ProvideStore,
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Provider              Provider
	Bucket                string
	KeyPath               string
	TargetPrincipal       string
	ImpersonationLifetime time.Duration
}

type FileSystemStore

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

func (*FileSystemStore) Download

func (c *FileSystemStore) Download(_ context.Context, filePath string) (io.ReadCloser, error)

func (FileSystemStore) GetSignedURL

func (c FileSystemStore) GetSignedURL(_ context.Context, _ string) (string, error)

func (FileSystemStore) Upload

func (c FileSystemStore) Upload(ctx context.Context,
	file io.Reader,
	filePath string,
) error

type GCSStore

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

func (*GCSStore) Download

func (c *GCSStore) Download(_ context.Context, _ string) (io.ReadCloser, error)

func (*GCSStore) GetSignedURL

func (c *GCSStore) GetSignedURL(ctx context.Context, filePath string) (string, error)

func (*GCSStore) Upload

func (c *GCSStore) Upload(ctx context.Context, file io.Reader, filePath string) error

type Provider

type Provider string
const (
	ProviderGCS        Provider = "gcs"
	ProviderFileSystem Provider = "filesystem"
)

type Store

type Store interface {
	// Upload uploads a file to the blob store.
	Upload(ctx context.Context, file io.Reader, filePath string) error

	// GetSignedURL returns the URL for a file in the blob store.
	GetSignedURL(ctx context.Context, filePath string) (string, error)

	// Download returns a reader for a file in the blob store.
	Download(ctx context.Context, filePath string) (io.ReadCloser, error)
}

func NewFileSystemStore

func NewFileSystemStore(cfg Config) (Store, error)

func NewGCSStore

func NewGCSStore(ctx context.Context, cfg Config) (Store, error)

func ProvideStore

func ProvideStore(ctx context.Context, config Config) (Store, error)

Jump to

Keyboard shortcuts

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