Categorygithub.com/TruthHun/CloudStore
modulepackage
0.0.0-20210408070537-c72f4795748c
Repository: https://github.com/truthhun/cloudstore.git
Documentation: pkg.go.dev

# README

CloudStore - 云储存集成

国内各大云存储服务接口集成,让云存储使用更方便简单。

目前集成的有:阿里云OSS,百度云BOS腾讯云COS华为云OBS七牛云又拍云Minio

为什么要有这个项目?

为了一劳永逸...

为了变得更懒...

如果上传文件到各大云存储,都变成下面这样:

clientBOS.Upload(tmpFile, saveFile)     // 百度云
clientCOS.Upload(tmpFile, saveFile)     // 腾讯云
clientMinio.Upload(tmpFile, saveFile)   // Minio
clientOBS.Upload(tmpFile, saveFile)     // 华为云
clientOSS.Upload(tmpFile, saveFile)     // 阿里云
clientUpYun.Upload(tmpFile, saveFile)   // 又拍云
clientQiniu.Upload(tmpFile, saveFile)   // 七牛云

如果各大云存储删除文件对象,都变成下面这样:

clientXXX.Delete(file1, file2, file3, ...)

不需要翻看各大云存储服务的一大堆文档,除了创建的客户端对象不一样之外,调用的方法和参数都一毛一样,会不会很爽?

目前初步实现的功能接口

type CloudStore interface {
	Delete(objects ...string) (err error)                                             // 删除文件
	GetSignURL(object string, expire int64) (link string, err error)                  // 文件访问签名
	IsExist(object string) (err error)                                                // 判断文件是否存在
	Lists(prefix string) (files []File, err error)                                    // 文件前缀,列出文件
	Upload(tmpFile string, saveFile string, headers ...map[string]string) (err error) // 上传文件
	Download(object string, savePath string) (err error)                              // 下载文件
	GetInfo(object string) (info File, err error)                                     // 获取指定文件信息
}

目前集成和实现的功能

TODO:

  • 注意,domain 参数要处理一下,最后统一不带"/"
  • 最后获取的签名链接,替换成绑定的域名
  • timeout 时间要处理一下,因为一些非内网方式上传文件,在大文件的时候,5分钟或者10分钟都有可能会超时
  • Lists方法在查询列表的时候,需要对prefix参数做下处理

注意

所有云存储的endpoint,在配置的时候都是不带 http://或者https://

DocHub 可用云存储

  • 百度云 BOS,需要自行压缩svg文件为gzip
  • 腾讯云 COS,需要自行压缩svg文件为gzip
  • 阿里云 OSS,需要自行压缩svg文件为gzip
  • Minio,需要自行压缩svg文件为gzip
  • 七牛云存储,在上传svg的时候不需要压缩,svg访问的时候,云存储自行压缩了
  • 又拍云,在上传svg的时候不需要压缩,svg访问的时候,云存储自行压缩了
  • 华为云 OBS,在上传svg的时候不需要压缩,svg访问的时候,云存储自行压缩了

# Packages

No description provided by the author

# Functions

No description provided by the author
MD5 Crypt.
new bos.
No description provided by the author
No description provided by the author
No description provided by the author
New OSS.
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author