storage

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStorage

type FileStorage interface {
	UploadFile(ctx context.Context, objectKey string, reader io.Reader) (string, error)
	DownloadFile(ctx context.Context, objectKey string) (io.ReadCloser, error)
	DeleteFile(ctx context.Context, objectKey string) error
	ListFiles(ctx context.Context) ([]string, error)
	Reset(ctx context.Context) error
}

FileStorage defines interface for file store

func NewFileStorage

func NewFileStorage(cfg interface{}) FileStorage

NewFileStorage creates a new file storages TODO: Support other types (GCS, S3) to deploy mock server as a cluster

type LocalStorage

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

LocalStorage define methods to access local storage

func NewLocalStorage

func NewLocalStorage(config LocalStorageConfig) *LocalStorage

NewLocalStorage creates a new instance of LocalStorage

func (*LocalStorage) DeleteFile

func (s *LocalStorage) DeleteFile(ctx context.Context, objectKey string) error

DeleteFile deletes file from local storage

func (*LocalStorage) DownloadFile

func (s *LocalStorage) DownloadFile(ctx context.Context, objectKey string) (io.ReadCloser, error)

DownloadFile writes file saved in local storage to writer

func (*LocalStorage) ListFiles

func (s *LocalStorage) ListFiles(ctx context.Context) ([]string, error)

ListFiles list all files

func (*LocalStorage) Reset

func (s *LocalStorage) Reset(ctx context.Context) error

Reset removes all files

func (*LocalStorage) UploadFile

func (s *LocalStorage) UploadFile(ctx context.Context, objectKey string, reader io.Reader) (string, error)

UploadFile reads from reader and saves to local storage

type LocalStorageConfig

type LocalStorageConfig struct {
	StoragePath string
	UseTempDir  bool
}

LocalStorageConfig defines config for local storage

Jump to

Keyboard shortcuts

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