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) (base.FileInterface, error) { result, err := Storage.GetStream(path) if f, ok := result.(base.FileInterface); ok { return f, err } if err == nil { buf := []byte{} if buf, err = io.ReadAll(result); err == nil { result := 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 *base.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 *base.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 ¶
type ClosingReadSeeker ¶
type ClosingReadSeeker struct {
io.ReadSeeker
}
ClosingReadSeeker implement Closer interface for ReadSeeker
func (ClosingReadSeeker) Close ¶
func (ClosingReadSeeker) Close() error
Close implement Closer interface for Buffer
Click to show internal directories.
Click to hide internal directories.