Documentation
¶
Index ¶
- Constants
- func Factories() []string
- func Register(name string, f Factory)
- func RegisterAssets()
- func UnregisterAll()
- type Assets
- type AssetsStoreConfig
- type Config
- type ConfigJSON
- type ConfigMap
- type Driver
- type Error
- type ErrorType
- type Factory
- type File
- type Option
- type OptionConfigJSON
- type OptionConfigMap
- type Store
Constants ¶
const ErrorTypeNotExists = "file-not-exists"
ErrorTypeNotExists error type file not exists.
ErrorTypeUnavailableID error type id unavailable
Variables ¶
This section is empty.
Functions ¶
func Factories ¶
func Factories() []string
Factories returns a sorted list of the names of the registered factories.
Types ¶
type Assets ¶
Assets local file store.
func (*Assets) Load ¶
func (f *Assets) Load(id string) (io.ReadCloser, error)
Load load file with given id. Return file reader any error if raised.
type AssetsStoreConfig ¶
type AssetsStoreConfig struct {
//URLHost file url host.
URLHost string
//URLPrefix file url path prefix
URLPrefix string
//Absolute if filepath is Absolute.
Absolute bool
//Root file root path.
//if Absolute is true,file root is based from root path.
//Otherwie file root is based from current working direction.
Root string
//Location file sub folder which stored in.
Location string
}
AssetsStoreConfig local file store config
func (*AssetsStoreConfig) Create ¶
func (c *AssetsStoreConfig) Create() (Driver, error)
Create create new local file driver. Return created driver and any error if raised.
type Config ¶
type Config interface {
//Get get value form given key.
//Return any error if raised.
Get(key string, v interface{}) error
}
Config confit interface
type ConfigJSON ¶
ConfigJSON JSON format config
func (*ConfigJSON) Get ¶
func (c *ConfigJSON) Get(key string, v interface{}) error
Get get value form given key. Return any error if raised.
func (*ConfigJSON) Set ¶
func (c *ConfigJSON) Set(key string, v interface{}) error
Set set value to given key. Return any error if raised.
type ConfigMap ¶
type ConfigMap map[string]interface{}
ConfigMap Map format config
type Driver ¶
type Driver interface {
//Save save data form reader to named file.
//Return file id ,file size and any error if raised.
Save(filename string, reader io.Reader) (id string, length int64, err error)
//Load load file with given id.
//Return file reader any error if raised.
Load(id string) (io.ReadCloser, error)
//Remove remove file by id.
//Return any error if raised.
Remove(id string) error
//URL convert file id to file url.
//Return file url and any error if raised.
URL(id string) (string, error)
}
Driver store driver interface.
type Error ¶
Error file store error.
func NewNotExistsError ¶
NewNotExistsError create new file not exists error.
func NewUnavailableIDError ¶
NewUnavailableIDError create new id not unavailablel error.
type File ¶
type File struct {
//Store store which field stored in
Store *Store
//ID file id
ID string
// contains filtered or unexported fields
}
File file stored.
type OptionConfigJSON ¶
type OptionConfigJSON struct {
Driver string
Config ConfigJSON
}
OptionConfigJSON option config in json format.
func NewOptionConfigJSON ¶
func NewOptionConfigJSON() *OptionConfigJSON
NewOptionConfigJSON create new option config.
func (*OptionConfigJSON) ApplyTo ¶
func (o *OptionConfigJSON) ApplyTo(store *Store) error
ApplyTo apply option to file store.
type OptionConfigMap ¶
OptionConfigMap option config in map format.
func NewOptionConfigMap ¶
func NewOptionConfigMap() *OptionConfigMap
NewOptionConfigMap create new option config.
func (*OptionConfigMap) ApplyTo ¶
func (o *OptionConfigMap) ApplyTo(store *Store) error
ApplyTo apply option to file store.