storage

package
v0.0.0-...-2588cc6 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// S3StorageURL is the url of the S3 storage.
	S3 = "s3"
)

Variables

View Source
var (
	// ErrUnknownStorage is the error of unknown storage.
	ErrUnknownStorage = errors.New("unknown storage")
)

Functions

This section is empty.

Types

type ExternalStorage

type ExternalStorage interface {
	// GetFile returns the file content of the given path.
	GetFile(filePath string) ([]byte, error)

	// PutFile puts the file content to the given path.
	PutFile(filePath string, content []byte) error

	// ListFiles returns the file names under the given path.
	ListFiles(dirPath string) ([]string, error)

	// ListSubDir returns the sub-directory of the given path.
	ListSubDir(rootDir string) ([]string, error)

	// DeleteFile deletes the file of the given path.
	DeleteFile(filePath string) error
}

func NewExternalStorage

func NewExternalStorage(storageType string, cfg *utils.StorageConfig) (ExternalStorage, error)

NewExternalStorage creates a new external storage.

func NewS3Storage

func NewS3Storage(cfg *utils.StorageConfig) ExternalStorage

NewS3Storage creates a new S3 client.

type S3Storage

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

S3Storage is aws S3 service.

func (*S3Storage) DeleteFile

func (s *S3Storage) DeleteFile(filePath string) error

DeleteFile deletes the file in the S3.

func (*S3Storage) GetFile

func (s *S3Storage) GetFile(key string) ([]byte, error)

GetFile gets the file from the S3.

func (*S3Storage) ListFiles

func (s *S3Storage) ListFiles(dirPath string) ([]string, error)

ListFiles lists the files in the S3.

func (*S3Storage) ListSubDir

func (s *S3Storage) ListSubDir(rootDir string) ([]string, error)

ListSubDir lists the sub-directory in the S3.

func (*S3Storage) PutFile

func (s *S3Storage) PutFile(key string, content []byte) error

PutFile puts the file to the S3.

Jump to

Keyboard shortcuts

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