storage

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingEnv         = errors.New("missing GOOGLE_CLOUD_SERVICE_ACCOUNT env var")
	ErrInvalidCredentials = errors.New("invalid credentials")
)

Functions

func GetCredentials

func GetCredentials(ctx context.Context) (*google.Credentials, error)

Types

type ContentType added in v0.1.10

type ContentType string
const (
	JSONTYPE ContentType = "application/json;charset=uft-8"
	IMAGEPNG ContentType = "image/png"
)

type GCSRepository

type GCSRepository struct {
	Bucket string
	// contains filtered or unexported fields
}

func NewGcsRepository

func NewGcsRepository(bucket string) *GCSRepository

func (*GCSRepository) Download

func (gcs *GCSRepository) Download(path string, toFile string) ([]byte, error)

func (*GCSRepository) Read

func (gcs *GCSRepository) Read(path string) ([]byte, error)

func (*GCSRepository) ReadImage

func (gcs *GCSRepository) ReadImage(path string) (image.Image, error)

func (*GCSRepository) Write

func (gcs *GCSRepository) Write(data []byte, output string, contentType ContentType) error

func (*GCSRepository) WriteImage

func (gcs *GCSRepository) WriteImage(data *image.RGBA, output string) error

type LocalStorage

type LocalStorage struct{}

func (LocalStorage) Read

func (LocalStorage) Read(path string) ([]byte, error)

func (LocalStorage) ReadImage

func (LocalStorage) ReadImage(path string) (image.Image, error)

func (LocalStorage) Write

func (LocalStorage) Write(data []byte, output string, contentType ContentType) error

func (LocalStorage) WriteImage

func (LocalStorage) WriteImage(data *image.RGBA, output string) error

type NFTStorage

type NFTStorage interface {
	Write(data []byte, output string, contentType ContentType) error
	WriteImage(data *image.RGBA, output string) error
	Read(path string) ([]byte, error)
	ReadImage(path string) (image.Image, error)
}

Jump to

Keyboard shortcuts

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