Git Product home page Git Product logo

cloudstore's Introduction

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访问的时候,云存储自行压缩了

cloudstore's People

Contributors

truthhun88 avatar athom avatar truthhun avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.