XAliyunOss

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2021 License: MIT Imports: 6 Imported by: 0

README

XAliyunOss Starter

基于 github.com/aliyun/aliyun-oss-go-sdk 包

AliyunOss Documentation

Documentation https://help.aliyun.com/product/31815.html?spm=a2c4g.750001.list.18.4afe7b13ZutdDu

Example: https://github.com/aliyun/aliyun-oss-go-sdk/tree/master/sample

Crypto Example: https://github.com/aliyun/aliyun-oss-go-sdk/blob/master/sample_crypto/sample_crypto.go

XAliyunOss Starter Usage
goinfras.RegisterStarter(XAliyunOss.NewStarter())

XAliyunOss Config Setting
AccessKeySecret string // 开发者AccessKeySecret
ConnTimeout     int    // 请求超时时间,包括连接超时、Socket读写超时,单位秒,默认连接超时30秒,读写超时60秒
RWTimeout       int    // 读写超时设置
EnableMD5       bool   // 是否开启MD5校验。推荐使用CRC校验,CRC的效率高于MD5
EnableCRC       bool   // 是否开启CRC校验
AuthProxy       string // 带账号密码的代理服务器
Proxy           string // 代理服务器,如http://8.8.8.8:3128
AccessKeyId     string //
BucketName      string // 存储库名
Endpoint        string // 机房节点
UseCname        bool   // 是否使用自定义域名CNAME
SecurityToken   string // 临时用户的SecurityToken
XAliyunOss Usage

// 实例使用请查看run_test.go


// 简单通用的上传下载实例
XAliyunOss.XCommonOss()

// 断点上传下载实例
XAliyunOss.XBreakPointOss()

// 分块上传下载实例
XAliyun.XMultipartOss()

// 含进度的上传下载实例
XAliyunOss.XProgressOss()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultClient

func CreateDefaultClient(config *Config) error

创建一个默认配置的Manager

func NewClient

func NewClient(cfg *Config) (*aliOss.Client, error)

func NewStarter

func NewStarter() *starter

func XClient

func XClient() *oss.Client

func XFClient

func XFClient(f func(c *oss.Client) error) error

资源组件闭包执行

Types

type BreakPointOss

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

断点上传和断点下载通用操作

func XBreakPointOss

func XBreakPointOss() *BreakPointOss

断点操作实例

func (*BreakPointOss) BreakPointDownload

func (bp *BreakPointOss) BreakPointDownload(objectKeyName, dstFilePath string) error

func (*BreakPointOss) BreakPointDownloadFromBucket added in v1.2.3

func (bp *BreakPointOss) BreakPointDownloadFromBucket(bucketName, objectKeyName, dstFilePath string) error

func (*BreakPointOss) BreakPointUpload

func (bp *BreakPointOss) BreakPointUpload(objectKeyName, localFilePath string) error

func (*BreakPointOss) BreakPointUploadToBucket added in v1.2.3

func (bp *BreakPointOss) BreakPointUploadToBucket(bucketName, objectKeyName, localFilePath string) error

type CommonAliyunOss

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

func XCommonOss

func XCommonOss() *CommonAliyunOss

通用实例

func (*CommonAliyunOss) AppendUpload

func (c *CommonAliyunOss) AppendUpload(objectKeyName string, appendContents ...string) error

func (*CommonAliyunOss) AppendUploadToBucket added in v1.2.3

func (c *CommonAliyunOss) AppendUploadToBucket(bucketName, objectKeyName string, appendContents ...string) error

追加上传

func (*CommonAliyunOss) CompressDownload

func (c *CommonAliyunOss) CompressDownload(objectKeyName, dstFilePath string) error

func (*CommonAliyunOss) CompressDownloadFromBucket added in v1.2.3

func (c *CommonAliyunOss) CompressDownloadFromBucket(bucketName, objectKeyName, dstFilePath string) error

文件压缩下载

func (*CommonAliyunOss) DownLoadFile

func (c *CommonAliyunOss) DownLoadFile(objectKeyName, dstFilePath string) error

func (*CommonAliyunOss) DownLoadFileFromBucket added in v1.2.3

func (c *CommonAliyunOss) DownLoadFileFromBucket(bucketName, objectKeyName, dstFilePath string) error

下载文件到本地

func (*CommonAliyunOss) LimitConditionDownload

func (c *CommonAliyunOss) LimitConditionDownload(objectKeyName, dstFilePath string, options ...aliOss.Option) error

func (*CommonAliyunOss) LimitConditionDownloadFromBucket added in v1.2.3

func (c *CommonAliyunOss) LimitConditionDownloadFromBucket(bucketName, objectKeyName, dstFilePath string, options ...aliOss.Option) error

限定条件下载

传入options条件参数:

参数 描述 如何设置 IfModifiedSince 如果指定的时间早于实际修改时间,则正常传输文件,否则返回错误(304 Not modified)。 oss.IfModifiedSince IfUnmodifiedSince 如果指定的时间等于或者晚于文件实际修改时间,则正常传输文件,否则返回错误(412 Precondition failed)。 oss.IfUnmodifiedSince IfMatch 如果指定的ETag和OSS文件的ETag匹配,则正常传输文件,否则返回错误(412 Precondition failed)。 oss.IfMatch IfNoneMatch 如果指定的ETag和OSS文件的ETag不匹配,则正常传输文件,否则返回错误(304 Not modified)。 oss.IfNoneMatch

func (*CommonAliyunOss) RangeDownload

func (c *CommonAliyunOss) RangeDownload(objectKeyName string, start, end int64) ([]byte, error)

func (*CommonAliyunOss) RangeDownloadFromBucket added in v1.2.3

func (c *CommonAliyunOss) RangeDownloadFromBucket(bucketName, objectKeyName string, start, end int64) ([]byte, error)

仅需要文件中的部分数据,您可以使用范围下载

func (*CommonAliyunOss) StreamDownload

func (c *CommonAliyunOss) StreamDownload(objectKeyName string) ([]byte, error)

func (*CommonAliyunOss) StreamDownloadFromBucket added in v1.2.3

func (c *CommonAliyunOss) StreamDownloadFromBucket(bucketName, objectKeyName string) ([]byte, error)

流下载

func (*CommonAliyunOss) UploadString

func (c *CommonAliyunOss) UploadString(objectKeyName, objectValue string) error

func (*CommonAliyunOss) UploadStringToBucket added in v1.2.3

func (c *CommonAliyunOss) UploadStringToBucket(bucketName, objectKeyName, objectValue string) error

上传普通数据

func (*CommonAliyunOss) Uploadfile

func (c *CommonAliyunOss) Uploadfile(objectKeyName, localFilePath string) error

func (*CommonAliyunOss) UploadfileToBucket added in v1.2.3

func (c *CommonAliyunOss) UploadfileToBucket(bucketName, objectKeyName, localFilePath string) error

上传普通文件

type Config

type Config struct {
	AccessKeyId     string //
	DefaultBucket   string // 存储库名
	AccessKeySecret string // 开发者AccessKeySecret
	Endpoint        string // 机房节点
	ConnTimeout     int    // 请求超时时间,包括连接超时、Socket读写超时,单位秒,默认连接超时30秒,读写超时60秒
	RWTimeout       int    // 读写超时设置
	EnableMD5       bool   // 是否开启MD5校验。推荐使用CRC校验,CRC的效率高于MD5
	EnableCRC       bool   // 是否开启CRC校验
	UseCname        bool   // 是否使用自定义域名CNAME
	AuthProxy       string // 带账号密码的代理服务器
	Proxy           string // 代理服务器,如http://8.8.8.8:3128
	SecurityToken   string // 临时用户的SecurityToken
}

func DefaultConfig

func DefaultConfig() *Config

type MultipartOss

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

func XMultipartOss

func XMultipartOss() *MultipartOss

分片上传操作实例

func (*MultipartOss) CancelMultipartUpload

func (mp *MultipartOss) CancelMultipartUpload(objectKeyName string) error

func (*MultipartOss) CancelMultipartUploadToBucket added in v1.2.3

func (mp *MultipartOss) CancelMultipartUploadToBucket(bucketName, objectKeyName string) error

取消分片上传

func (*MultipartOss) MultipartUpload

func (mp *MultipartOss) MultipartUpload(objectKeyName, localFilePath string) (*aliOss.CompleteMultipartUploadResult, error)

func (*MultipartOss) MultipartUploadToBucket added in v1.2.3

func (mp *MultipartOss) MultipartUploadToBucket(bucketName, objectKeyName, localFilePath string) (*aliOss.CompleteMultipartUploadResult, error)

type ProgressOss

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

func XProgressOss

func XProgressOss() *ProgressOss

含进度的上传下载操作实例

func (*ProgressOss) ProgressDownload

func (p *ProgressOss) ProgressDownload(objectKeyName, dstFilePath string) error

func (*ProgressOss) ProgressDownloadFromBucket added in v1.2.3

func (p *ProgressOss) ProgressDownloadFromBucket(bucketName, objectKeyName, dstFilePath string) error

下载使用进度条

func (*ProgressOss) ProgressUpload

func (p *ProgressOss) ProgressUpload(objectKeyName, localFilePath string) error

func (*ProgressOss) ProgressUploadToBucket added in v1.2.3

func (p *ProgressOss) ProgressUploadToBucket(bucketName, objectKeyName, localFilePath string) error

上传使用进度条

Jump to

Keyboard shortcuts

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