blob

package
v0.0.0-...-087ca59 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProviderNotFound = errors.New("blob provider not found")

Functions

This section is empty.

Types

type Container

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

func NewBlobContainer

func NewBlobContainer() *Container

func (*Container) Save

func (c *Container) Save(ctx context.Context, b *CreateBlobInfo) (*SaveResult, error)

type CreateBlobInfo

type CreateBlobInfo struct {
	Name         string
	Size         int64
	Blob         io.Reader
	ContentType  string
	ProviderType *ProviderType
	KeepName     bool // keep original name as key

	Metadata map[string]string
}

type CreatedEventData

type CreatedEventData struct {
	Path   string `json:"fileName"`
	Size   int64  `json:"size"`
	Result *SaveResult
}

type Options

type Options struct {

	// UseDefaultProvider if true, then if provider not found, default provider will be used
	// default value is true
	UserDefaultProvider bool
	ProvidersConfig     map[ProviderType]map[string]any `mapstructure:"Providers"`
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions() *Options

func (*Options) AddProvider

func (opts *Options) AddProvider(providerType ProviderType, provider Provider) *Options

func (*Options) DefaultProvider

func (opts *Options) DefaultProvider() Provider

func (*Options) GetConfig

func (opts *Options) GetConfig(t ProviderType, key string) any

func (*Options) GetProvider

func (opts *Options) GetProvider(providerType ProviderType) Provider

func (*Options) Handlers

func (opts *Options) Handlers() []SavedHandleFunc

func (*Options) OnSaved

func (opts *Options) OnSaved(handler SavedHandleFunc) *Options

func (*Options) SetDefaultProvider

func (opts *Options) SetDefaultProvider(provider Provider) *Options

type Provider

type Provider interface {
	Save(ctx context.Context, b *CreateBlobInfo) (*SaveResult, error)
}

type ProviderType

type ProviderType string

type SaveResult

type SaveResult struct {
	Url string `json:"url"`
}

type SavedHandleFunc

type SavedHandleFunc func(ctx context.Context, b *CreatedEventData) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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