storage

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OperationUpload   = pkgfs.OperationUpload
	OperationDownload = pkgfs.OperationDownload
	OperationGet      = pkgfs.OperationGet
	OperationDelete   = pkgfs.OperationDelete
	OperationList     = pkgfs.OperationList
	OperationSource   = pkgfs.OperationSource
	OperationToken    = pkgfs.OperationToken

	UploadModeLocalChunk   = core.UploadModeLocalChunk
	UploadModeDirectPut    = core.UploadModeDirectPut
	UploadModeMultipartPut = core.UploadModeMultipartPut

	HookBeforeUpload        = pkgfs.HookBeforeUpload
	HookAfterUpload         = pkgfs.HookAfterUpload
	HookAfterUploadFailed   = pkgfs.HookAfterUploadFailed
	HookBeforeDownload      = pkgfs.HookBeforeDownload
	HookAfterDownload       = pkgfs.HookAfterDownload
	HookAfterDownloadFailed = pkgfs.HookAfterDownloadFailed
	HookBeforeGet           = pkgfs.HookBeforeGet
	HookAfterGet            = pkgfs.HookAfterGet
	HookAfterGetFailed      = pkgfs.HookAfterGetFailed
	HookBeforeDelete        = pkgfs.HookBeforeDelete
	HookAfterDelete         = pkgfs.HookAfterDelete
	HookAfterDeleteFailed   = pkgfs.HookAfterDeleteFailed
	HookBeforeList          = pkgfs.HookBeforeList
	HookAfterList           = pkgfs.HookAfterList
	HookAfterListFailed     = pkgfs.HookAfterListFailed
	HookBeforeSource        = pkgfs.HookBeforeSource
	HookAfterSource         = pkgfs.HookAfterSource
	HookAfterSourceFailed   = pkgfs.HookAfterSourceFailed
	HookBeforeToken         = pkgfs.HookBeforeToken
	HookAfterToken          = pkgfs.HookAfterToken
	HookAfterTokenFailed    = pkgfs.HookAfterTokenFailed
)
View Source
const (
	DefaultStoreName = "default"
)
View Source
const KeyStorage runtime.Key = "storage"

Variables

View Source
var (
	ErrNotConfigured   = errors.New("storage: not configured")
	ErrDefaultRequired = errors.New("storage: default store is required")
	ErrStoreNotFound   = errors.New("storage: store not found")
)
View Source
var (
	ErrFileTooBig             = core.ErrFileTooBig
	ErrFileExists             = core.ErrFileExists
	ErrFileNotFound           = core.ErrFileNotFound
	ErrNameInvalid            = core.ErrNameInvalid
	ErrUnknownDriver          = core.ErrUnknownDriver
	ErrSourceExpired          = core.ErrSourceExpired
	ErrSourceSignatureInvalid = core.ErrSourceSignatureInvalid
	ErrSourceSecretRequired   = core.ErrSourceSecretRequired
)

Functions

func AccessPath added in v0.1.3

func AccessPath(name string, objectPath string) string

func Bind

func Bind(app *runtime.App, manager *Manager) error

func Close

func Close() error

func CropImage

func CropImage(reader io.Reader, writer io.Writer, rect CropRect, format string, quality int) error

func DefaultCDNURL added in v0.1.3

func DefaultCDNURL() string

func HookValidateFile

func HookValidateFile(ctx context.Context, event Event) error

func SetDefault

func SetDefault(manager *Manager)

func SourceHandler

func SourceHandler(fs *FileSystem, secret string) http.Handler

func ValidateImageInfo

func ValidateImageInfo(info ImageInfo, limit ImageLimit) error

Types

type Config

type Config struct {
	Default string                 `mapstructure:"default" yaml:"default"`
	Stores  map[string]StoreConfig `mapstructure:"stores" yaml:"stores"`
}

type CropRect

type CropRect = pkgfs.CropRect

type DeleteResult

type DeleteResult = pkgfs.DeleteResult

type DownloadResult

type DownloadResult = pkgfs.DownloadResult

type DriverConfig

type DriverConfig = core.DriverConfig

type Event

type Event = pkgfs.Event

type FileHeader

type FileHeader = core.FileHeader

type FileInfo

type FileInfo = core.FileInfo

type FileStream

type FileStream = core.FileStream

func NewFileStream

func NewFileStream(reader io.Reader, info FileInfo) *FileStream

type FileSystem

type FileSystem = pkgfs.FileSystem

func Default

func Default() (*FileSystem, error)

func New

func New(policy Policy, opts ...Option) (*FileSystem, error)

func NewFileSystem

func NewFileSystem(policy Policy, opts ...Option) (*FileSystem, error)

func NewFromPolicy

func NewFromPolicy(policy core.StoragePolicy, opts ...pkgfs.Option) (*FileSystem, error)

func Use

func Use(name string) (*FileSystem, error)

type GetResult

type GetResult = pkgfs.GetResult

type Handler

type Handler = core.Handler

type Hook

type Hook = pkgfs.Hook

type HookOption

type HookOption = pkgfs.HookOption

func AfterDelete

func AfterDelete(hook Hook) HookOption

func AfterDeleteFailed

func AfterDeleteFailed(hook Hook) HookOption

func AfterDownload

func AfterDownload(hook Hook) HookOption

func AfterDownloadFailed

func AfterDownloadFailed(hook Hook) HookOption

func AfterGet

func AfterGet(hook Hook) HookOption

func AfterGetFailed

func AfterGetFailed(hook Hook) HookOption

func AfterList

func AfterList(hook Hook) HookOption

func AfterListFailed

func AfterListFailed(hook Hook) HookOption

func AfterSource

func AfterSource(hook Hook) HookOption

func AfterSourceFailed

func AfterSourceFailed(hook Hook) HookOption

func AfterToken

func AfterToken(hook Hook) HookOption

func AfterTokenFailed

func AfterTokenFailed(hook Hook) HookOption

func AfterUpload

func AfterUpload(hook Hook) HookOption

func AfterUploadFailed

func AfterUploadFailed(hook Hook) HookOption

func BeforeDelete

func BeforeDelete(hook Hook) HookOption

func BeforeDownload

func BeforeDownload(hook Hook) HookOption

func BeforeGet

func BeforeGet(hook Hook) HookOption

func BeforeList

func BeforeList(hook Hook) HookOption

func BeforeSource

func BeforeSource(hook Hook) HookOption

func BeforeToken

func BeforeToken(hook Hook) HookOption

func BeforeUpload

func BeforeUpload(hook Hook) HookOption

func HookMetadata

func HookMetadata(key string, value any) HookOption

type ImageInfo

type ImageInfo = pkgfs.ImageInfo

func DecodeImageInfo

func DecodeImageInfo(reader io.Reader) (ImageInfo, error)

type ImageLimit

type ImageLimit = pkgfs.ImageLimit

type ListResult

type ListResult = pkgfs.ListResult

type Manager

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

func From

func From(app *runtime.App) *Manager

func ManagerDefault

func ManagerDefault() (*Manager, error)

func NewManager

func NewManager(cfg Config) (*Manager, error)

func (*Manager) AccessPath added in v0.1.3

func (m *Manager) AccessPath(name string, objectPath string) string

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Config

func (m *Manager) Config(name string) (StoreConfig, error)

func (*Manager) Default

func (m *Manager) Default() (*FileSystem, error)

func (*Manager) DefaultName

func (m *Manager) DefaultName() string

func (*Manager) New

func (m *Manager) New(policy Policy, opts ...Option) (*FileSystem, error)

func (*Manager) Policy

func (m *Manager) Policy(name string) (Policy, error)

func (*Manager) Use

func (m *Manager) Use(name string) (*FileSystem, error)

type Object

type Object = core.Object

type Option

type Option = pkgfs.Option

func WithAllowedExtensions

func WithAllowedExtensions(exts ...string) Option

func WithChunkSize

func WithChunkSize(chunkSize int64) Option

func WithMaxSize

func WithMaxSize(maxSize int64) Option

func WithNameRules

func WithNameRules(dirRule, fileRule string) Option

func WithTempDir

func WithTempDir(tempDir string) Option

func WithTokenTTL

func WithTokenTTL(ttl time.Duration) Option

type Policy

type Policy = core.StoragePolicy

func PolicyOf

func PolicyOf(name string) (Policy, error)

type SourceResult

type SourceResult = pkgfs.SourceResult

type StoreConfig

type StoreConfig struct {
	Driver            string        `mapstructure:"driver" yaml:"driver"`
	TempDir           string        `mapstructure:"temp_dir" yaml:"temp_dir"`
	MaxSize           int64         `mapstructure:"max_size" yaml:"max_size"`
	ChunkSize         int64         `mapstructure:"chunk_size" yaml:"chunk_size"`
	TokenTTL          time.Duration `mapstructure:"token_ttl" yaml:"token_ttl"`
	DirRule           string        `mapstructure:"dir_rule" yaml:"dir_rule"`
	FileRule          string        `mapstructure:"file_rule" yaml:"file_rule"`
	AllowedExtensions []string      `mapstructure:"allowed_extensions" yaml:"allowed_extensions"`

	Name          string `mapstructure:"name" yaml:"name"`
	Bucket        string `mapstructure:"bucket" yaml:"bucket"`
	Endpoint      string `mapstructure:"endpoint" yaml:"endpoint"`
	EndpointInner string `mapstructure:"endpoint_inner" yaml:"endpoint_inner"`
	CDNURL        string `mapstructure:"cdn_url" yaml:"cdn_url"`
	Region        string `mapstructure:"region" yaml:"region"`
	AccessKey     string `mapstructure:"access_key" yaml:"access_key"`
	SecretKey     string `mapstructure:"secret_key" yaml:"secret_key"`
	SecretID      string `mapstructure:"secret_id" yaml:"secret_id"`
	AccessKeyID   string `mapstructure:"access_key_id" yaml:"access_key_id"`
	AccessSecret  string `mapstructure:"access_secret" yaml:"access_secret"`
	Dir           string `mapstructure:"dir" yaml:"dir"`
	LocalDir      string `mapstructure:"local_dir" yaml:"local_dir"`

	Policy       Policy            `mapstructure:"policy" yaml:"policy"`
	DriverConfig core.DriverConfig `mapstructure:",remain" yaml:",inline"`
}

func (StoreConfig) Clone

func (c StoreConfig) Clone() StoreConfig

type TokenResult

type TokenResult = pkgfs.TokenResult

type UploadChunkResult

type UploadChunkResult = pkgfs.UploadChunkResult

type UploadCredential

type UploadCredential = core.UploadCredential

type UploadInitRequest

type UploadInitRequest = pkgfs.UploadInitRequest

type UploadResult

type UploadResult = pkgfs.UploadResult

type UploadSession

type UploadSession = pkgfs.UploadSession

type UploadStatus

type UploadStatus = pkgfs.UploadStatus

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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