Documentation
¶
Index ¶
- Variables
- func CheckPath(path string, protocol Protocol) bool
- func DownloadUrlToBytes(url string) ([]byte, error)
- func FilterParams(path string) string
- func GetFilePathFromTotalPath(path string) string
- func MakePublicURL(domain, path string) (string, error)
- func Register(name Protocol, provider Provider)
- func ReplaceDomain(origin string, replaceDomain string) (string, error)
- func Url(path string, secure bool, expire ...time.Duration) (string, error)
- type Protocol
- type Provider
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func DownloadUrlToBytes ¶
DownloadUrlToBytes 读取下载链接对应资源为字节数组
func FilterParams ¶
func GetFilePathFromTotalPath ¶
GetFilePathFromTotalPath 从protocol://filePath获取具体中文件路径
func MakePublicURL ¶
Types ¶
type Provider ¶
type Provider interface { // Protocol 获取当前存储管理器的存储文件协议,最终返回的文件路径会带上该协议和://分隔符。 Protocol() Protocol // SimpleUploadToken 获取客户端简单上传凭证 SimpleUploadToken() string // Save 将指定的文件进行存储并返回存储成功后该文件在该存储器中的文件路径,失败则抛出异常。 // @return 文件路径,格式为:protocol://path Save(reader io.Reader, fileSize int64, filePath string) (string, error) // Get 根据指定的文件路径从存储器中获取文件内容,如果不存在或读取异常则抛出异常。 // @param path 存储器中文件的路径,格式为:protocol://path Get(path string) ([]byte, error) // Write 从存储器中读取给定路径的文件并将文件流输出到指定的输出流中,如果出错则抛出异常。 //@param path 存储器中文件的路径,格式为:protocol://path Write(path string, file *[]byte) error // Delete 从存储器中删除指定路径的文件,如果删除出错则抛出异常。 // @param path 存储器中文件的路径,格式为:protocol://path Delete(path string) error // Url 获取指定路径的文件的访问URL地址,必须是通过HTTP可以访问的URL路径地址。 // @param path 存储器中文件的路径,格式为:protocol://path // @param secure 是否使用安全访问链接,如果是则链接有类似过期限制、访问来源限制等安全特性,取决于实现类。 Url(path string, secure bool, expire ...time.Duration) (string, error) // Has 检查存储中是否存在指定文件路径的文件,如果不存在则返回false,否则返回true。 // @param path 格式为:protocol://path Has(path string) (bool, error) }
Provider 文件存储的接口定义,提供统一的文件存储管理服务。
func GetProvider ¶
Click to show internal directories.
Click to hide internal directories.