storage 是 infrago 的模块。
- 类型:模块
- 作用:对象存储模块,负责上传下载、URL 签名、元数据处理。
- 对上提供统一模块接口
- 对下通过驱动接口接入具体后端
- 支持按配置切换驱动实现
- 支持按文件类型注册缩略图/预览处理器
import _ "github.com/infrago/storage"[storage]
driver = "default"import "github.com/infrago/storage"
import "github.com/infrago/infra"
storage.Thumbnail(code, 320, 0, 0)
infra.Register("svg", storage.Thumbnailer{
Action: func(file *storage.File, width, height, position int64) (string, error) {
return "", nil
},
})以下接口由驱动实现(来自模块 driver.go):
Connect(*Instance) (Connection, error)
io.Readerio.Seekerio.Closerio.ReaderAt
Open() errorHealth() HealthClose() errorUpload(string, UploadOption) (*File, error)Fetch(*File, FetchOption) (Stream, error)Download(*File, DownloadOption) (string, error)Remove(*File, RemoveOption) errorBrowse(*File, BrowseOption) (string, error)
配置段:[storage]
- 未检测到配置键(请查看模块源码的 configure 逻辑)
setting一般用于向具体驱动透传专用参数- 多实例配置请参考模块源码中的 Config/configure 处理逻辑