storage

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileStorage = "file"
	S3Storage   = "s3"
)

Variables

This section is empty.

Functions

func CreateDirIfNotExist added in v0.0.9

func CreateDirIfNotExist(dir string) error

CreateDirIfNotExist creates the directory for the given file path if it does not exist.

Types

type File

type File struct {
}

func (File) DeleteObject added in v0.0.6

func (f File) DeleteObject(identifier string) error

func (File) GetObject added in v0.0.6

func (f File) GetObject(identifier string) (Object, error)

func (File) ListObject added in v0.0.6

func (f File) ListObject(prefix string) ([]Object, error)

func (File) PutObject

func (f File) PutObject(identifier string, data []byte) error

type Object added in v0.0.6

type Object struct {
	Path         string
	Content      []byte
	LastModified time.Time
}

type S3 added in v0.0.7

type S3 struct {
	Endpoint        string
	Bucket          string
	Region          string
	AccessKeyID     string
	SecretAccessKey string
	// contains filtered or unexported fields
}

func New added in v0.0.7

func New(endpoint, bucket, region, accessKeyID, secretAccessKey string) (*S3, error)

func (S3) DeleteObject added in v0.0.7

func (s S3) DeleteObject(identifier string) error

func (S3) GetObject added in v0.0.7

func (s S3) GetObject(identifier string) (Object, error)

func (S3) ListObject added in v0.0.7

func (s S3) ListObject(prefix string) ([]Object, error)

func (S3) PutObject added in v0.0.7

func (s S3) PutObject(identifier string, data []byte) error

type Storage

type Storage interface {
	// ListObject returns a list of all objects in the storage backend.
	ListObject(prefix string) ([]Object, error)
	// GetObject returns the object identified by the given identifier.
	GetObject(identifier string) (Object, error)
	// PutObject stores the data in the storage backend identified by the given identifier.
	PutObject(identifier string, data []byte) error
	// DeleteObject deletes the object identified by the given identifier.
	DeleteObject(identifier string) error
}

func GetStorage added in v0.1.2

func GetStorage(storage typedef.MultiStorage) (Storage, error)

Jump to

Keyboard shortcuts

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