storage

package
v1.4.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingConfigS3       = errors.New("missing config: s3")
	ErrMissingConfigFS       = errors.New("missing config: fs")
	ErrMissingConfigIPFS     = errors.New("missing config: ipfs")
	ErrUnsupprtedStorageType = errors.New("unsupported storage type")
	ErrEmptyContent          = errors.New("content empty")
	ErrContentSizeExceeded   = errors.New("content size exceeded")
	ErrDiskReservationLimit  = errors.New("disk reservation limit")
)
View Source
var InvalidHmacAlgType = errors.New("invalid HmacAlgType type")
View Source
var InvalidStorageType = errors.New("invalid StorageType type")

Functions

func IsPathExists

func IsPathExists(path string) bool

Types

type HmacAlgType

type HmacAlgType uint8
const (
	HMAC_ALG_TYPE_UNKNOWN HmacAlgType = iota
	HMAC_ALG_TYPE__MD5
	HMAC_ALG_TYPE__SHA1
	HMAC_ALG_TYPE__SHA256
)

func ParseHmacAlgTypeFromLabel

func ParseHmacAlgTypeFromLabel(s string) (HmacAlgType, error)

func ParseHmacAlgTypeFromString

func ParseHmacAlgTypeFromString(s string) (HmacAlgType, error)

func (HmacAlgType) Base64Sum

func (v HmacAlgType) Base64Sum(content []byte) string

func (HmacAlgType) ConstValues

func (v HmacAlgType) ConstValues() []enum.IntStringerEnum

func (HmacAlgType) HexSum

func (v HmacAlgType) HexSum(content []byte) string

func (HmacAlgType) Int

func (v HmacAlgType) Int() int

func (HmacAlgType) Label

func (v HmacAlgType) Label() string

func (HmacAlgType) MarshalText

func (v HmacAlgType) MarshalText() ([]byte, error)

func (*HmacAlgType) Scan

func (v *HmacAlgType) Scan(src interface{}) error

func (HmacAlgType) String

func (v HmacAlgType) String() string

func (HmacAlgType) Sum

func (v HmacAlgType) Sum(content []byte) []byte

func (HmacAlgType) Type

func (v HmacAlgType) Type() string

func (HmacAlgType) TypeName

func (v HmacAlgType) TypeName() string

func (*HmacAlgType) UnmarshalText

func (v *HmacAlgType) UnmarshalText(data []byte) error

func (HmacAlgType) Value

func (v HmacAlgType) Value() (driver.Value, error)

type LocalFs

type LocalFs struct {
	Root string `env:""`
}

func (*LocalFs) Delete

func (l *LocalFs) Delete(key string) error

func (*LocalFs) Init

func (l *LocalFs) Init() error

func (*LocalFs) Read

func (l *LocalFs) Read(key string, chk ...HmacAlgType) (data []byte, sum []byte, err error)

func (*LocalFs) SetDefault

func (l *LocalFs) SetDefault()

func (*LocalFs) Type

func (l *LocalFs) Type() StorageType

func (*LocalFs) Upload

func (l *LocalFs) Upload(key string, data []byte, chk ...HmacAlgType) error

Upload key full path with filename

type S3

type S3 struct {
	Endpoint         string         `env:""`
	Region           string         `env:""`
	AccessKeyID      string         `env:""`
	SecretAccessKey  types.Password `env:""`
	SessionToken     string         `env:""`
	BucketName       string         `env:""`
	UrlExpire        types.Duration `env:""`
	S3ForcePathStyle bool           `env:""`
	// contains filtered or unexported fields
}

func (*S3) Delete

func (s *S3) Delete(key string) error

func (*S3) DownloadUrl

func (s *S3) DownloadUrl(key string) (string, error)

func (*S3) Init

func (s *S3) Init() error

func (*S3) IsZero

func (s *S3) IsZero() bool

func (*S3) Name

func (s *S3) Name() string

func (*S3) Read

func (s *S3) Read(key string, chk ...HmacAlgType) (data []byte, sum []byte, err error)

func (*S3) SetDefault

func (s *S3) SetDefault()

func (*S3) Type

func (s *S3) Type() StorageType

func (*S3) Upload

func (s *S3) Upload(key string, data []byte, chk ...HmacAlgType) error

type Storage

type Storage struct {
	Typ             StorageType
	FilesizeLimit   int64
	DiskReserve     int64
	PromiscuousMode bool // PromiscuousMode if support multi storage type
	TempDir         string

	*S3      `env:"S3"`
	*LocalFs `env:"Fs"`
	// contains filtered or unexported fields
}

func (*Storage) Delete

func (s *Storage) Delete(key string) error

func (*Storage) Init

func (s *Storage) Init() error

func (*Storage) IsZero

func (s *Storage) IsZero() bool

func (*Storage) Name

func (s *Storage) Name() string

func (*Storage) Read

func (s *Storage) Read(key string, chk ...HmacAlgType) ([]byte, []byte, error)

func (*Storage) SetDefault

func (s *Storage) SetDefault()

func (*Storage) Type

func (s *Storage) Type() StorageType

func (*Storage) Upload

func (s *Storage) Upload(key string, content []byte, chk ...HmacAlgType) error

func (*Storage) Validate

func (s *Storage) Validate(data []byte, sum string, chk ...HmacAlgType) bool

func (*Storage) WithOperation

func (s *Storage) WithOperation(op StorageOperations)

type StorageOperations

type StorageOperations interface {
	Type() StorageType
	Upload(key string, file []byte, chk ...HmacAlgType) error
	Read(key string, chk ...HmacAlgType) (data []byte, sum []byte, err error)
	Delete(key string) error
}

type StorageOperationsWithValidation

type StorageOperationsWithValidation interface {
	Validate(data []byte, sum string, chk ...HmacAlgType) bool
}

type StorageType

type StorageType uint8
const (
	STORAGE_TYPE_UNKNOWN StorageType = iota
	STORAGE_TYPE__S3
	STORAGE_TYPE__FILESYSTEM
	STORAGE_TYPE__IPFS
)

func ParseStorageTypeFromLabel

func ParseStorageTypeFromLabel(s string) (StorageType, error)

func ParseStorageTypeFromString

func ParseStorageTypeFromString(s string) (StorageType, error)

func (StorageType) ConstValues

func (v StorageType) ConstValues() []enum.IntStringerEnum

func (StorageType) Int

func (v StorageType) Int() int

func (StorageType) Label

func (v StorageType) Label() string

func (StorageType) MarshalText

func (v StorageType) MarshalText() ([]byte, error)

func (*StorageType) Scan

func (v *StorageType) Scan(src interface{}) error

func (StorageType) String

func (v StorageType) String() string

func (StorageType) TypeName

func (v StorageType) TypeName() string

func (*StorageType) UnmarshalText

func (v *StorageType) UnmarshalText(data []byte) error

func (StorageType) Value

func (v StorageType) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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