unioss

package module
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

unioss

介绍

go语言封装云OSS文件上传

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	AliYunConst  = "aliYun"
	TencentConst = "tencent"
	QinNiuConst  = "qiNiu"
	MinioConst   = "minio"
)
View Source
const (
	TempFileSuffix = ".temp" // Temp file suffix
)

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(ossName string, config Config) error

Types

type AliYun

type AliYun struct {
	// contains filtered or unexported fields
}

func NewAliYun added in v1.0.3

func NewAliYun(config Config) (*AliYun, error)

func (*AliYun) DeleteObject

func (aliYun *AliYun) DeleteObject(objectKey string) error

DeleteObject 删除文件

func (*AliYun) GetObjectToFile

func (aliYun *AliYun) GetObjectToFile(objectKey, filePath string) error

GetObjectToFile 获取文件

func (*AliYun) GetObjectUrl

func (aliYun *AliYun) GetObjectUrl(objectKey string) string

GetObjectUrl 获取访问URL

func (*AliYun) IsExists

func (aliYun *AliYun) IsExists(objectKey string) (bool, error)

func (*AliYun) PutObject

func (aliYun *AliYun) PutObject(objectKey string, reader io.Reader) error

func (*AliYun) PutObjectFromFile

func (aliYun *AliYun) PutObjectFromFile(objectKey, filePath string) error

type Config

type Config struct {
	// (必填,对应阿里云access_key_id、腾讯云secret_id,七牛云accessKey)
	KeyId string
	// (必填,对应阿里云access_key_secret、腾讯云secret_key,七牛云secretKey)
	KeySecret string
	Bucket    string
	// 阿里云必填
	Endpoint string
	// 腾讯云必填
	AppId string
	// 腾讯云必填
	Region string
	// 域名
	Domain string
	// 是否私有 (仅七牛云)
	Private bool
	// 是否使用Https(Minio)
	UseSSL bool
}

type Minio added in v1.0.3

type Minio struct {
	// contains filtered or unexported fields
}

func NewMinio added in v1.0.3

func NewMinio(config Config) (*Minio, error)

func (*Minio) DeleteObject added in v1.0.3

func (mini *Minio) DeleteObject(objectKey string) error

DeleteObject 删除文件

func (*Minio) GetObjectToFile added in v1.0.3

func (mini *Minio) GetObjectToFile(objectKey, filePath string) error

GetObjectToFile 获取文件

func (*Minio) GetObjectUrl added in v1.0.3

func (mini *Minio) GetObjectUrl(objectKey string) string

GetObjectUrl 获取访问URL

func (*Minio) IsExists added in v1.0.3

func (mini *Minio) IsExists(objectKey string) (bool, error)

func (*Minio) PutObject added in v1.0.3

func (mini *Minio) PutObject(objectKey string, reader io.Reader) error

func (*Minio) PutObjectFromFile added in v1.0.3

func (mini *Minio) PutObjectFromFile(objectKey, filePath string) error

type QiNiu

type QiNiu struct {
	// contains filtered or unexported fields
}

func NewQiNiu added in v1.0.3

func NewQiNiu(config Config) (*QiNiu, error)

func (*QiNiu) DeleteObject

func (q *QiNiu) DeleteObject(objectKey string) error

DeleteObject 删除文件

func (*QiNiu) GetObjectToFile

func (q *QiNiu) GetObjectToFile(objectKey, filePath string) error

GetObjectToFile 获取文件

func (*QiNiu) GetObjectUrl

func (q *QiNiu) GetObjectUrl(objectKey string) string

GetObjectUrl 获取访问URL

func (*QiNiu) IsExists

func (q *QiNiu) IsExists(objectKey string) (bool, error)

func (*QiNiu) PutObject

func (q *QiNiu) PutObject(objectKey string, reader io.Reader) error

func (*QiNiu) PutObjectFromFile

func (q *QiNiu) PutObjectFromFile(objectKey, filePath string) error

type Storage

type Storage interface {
	GetObjectToFile(objectKey, downloadedFileName string) error
	DeleteObject(objectKey string) error
	PutObject(objectKey string, reader io.Reader) error
	PutObjectFromFile(objectKey, filePath string) error
	IsExists(objectKey string) (bool, error)
	GetObjectUrl(objectKey string) string
}

func GetStorage

func GetStorage() (Storage, error)

type Tencent

type Tencent struct {
	// contains filtered or unexported fields
}

func NewTencent added in v1.0.3

func NewTencent(config Config) (*Tencent, error)

func (*Tencent) DeleteObject

func (t *Tencent) DeleteObject(objectKey string) error

删除文件

func (*Tencent) GetObjectToFile

func (t *Tencent) GetObjectToFile(objectKey, filePath string) error

获取文件

func (*Tencent) GetObjectUrl

func (t *Tencent) GetObjectUrl(objectKey string) string

GetObjectUrl 获取访问URL

func (*Tencent) IsExists

func (t *Tencent) IsExists(objectKey string) (bool, error)

func (*Tencent) PutObject

func (t *Tencent) PutObject(objectKey string, reader io.Reader) error

func (*Tencent) PutObjectFromFile

func (t *Tencent) PutObjectFromFile(objectKey, filePath string) error

PutObjectFromFile 上传文件

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL