Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // URLTemplate default URL template URLTemplate = "/system/{{class}}/{{primary_key}}/{{column}}/{{filename_with_hash}}" // Storage the storage used to save medias Storage oss.StorageInterface = filesystem.New("public") )
View Source
var DefaultRetrieveHandler = func(oss OSS, path string) (media.FileInterface, error) { result, err := Storage.GetStream(path) if f, ok := result.(media.FileInterface); ok { return f, err } if err == nil { buf := []byte{} if buf, err = ioutil.ReadAll(result); err == nil { result := utils.ClosingReadSeeker{bytes.NewReader(buf)} result.Seek(0, 0) return result, err } } return nil, err }
DefaultRetrieveHandler used to retrieve file
View Source
var DefaultStoreHandler = func(oss OSS, path string, option *media.Option, reader io.Reader) error { _, err := Storage.Put(path, reader) return err }
DefaultStoreHandler used to store reader with default Storage
View Source
var DefaultURLTemplateHandler = func(oss OSS, option *media.Option) (url string) { if url = option.Get("URL"); url == "" { url = URLTemplate } url = strings.Join([]string{strings.TrimSuffix(Storage.GetEndpoint(), "/"), strings.TrimPrefix(url, "/")}, "/") if strings.HasPrefix(url, "/") { return url } for _, prefix := range []string{"https://", "http://"} { url = strings.TrimPrefix(url, prefix) } return "//" + url }
DefaultURLTemplateHandler used to generate URL and save into database
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.