XQiniuOss

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: 14 Imported by: 0

README

XQiniuOss Starter

基于 https://github.com/qiniu/api.v7

QiniuOss Documentation

Documentation https://developer.qiniu.com/kodo/sdk/1238/go

Example https://github.com/qiniu/api.v7/tree/master/examples

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

XQiniuOss Config Setting
AccessKey        string // 开发者key
SecretKey        string // 开发者secret
Bucket           string // 存储库名
UseHTTPS         bool   // 是否使用https域名
UseCdnDomains    bool   // 上传是否使用CDN上传加速
UpTokenExpires   int    // 上传凭证有效期
CallbackURL      string // 上传回调地址
CallbackBodyType string // 上传回调信息格式
EndUser          string // 唯一宿主标识
FsizeMin         int    // 限定上传文件大小最小值,单位Byte。
FsizeMax         int    // 限定上传文件大小最大值,单位Byte。超过限制上传文件大小的最大值会被判为上传失败,返回 413 状态码。
MimeLimit        string // 限定上传类型

XQiniuOss Usage

1 、 客户端上传下载

var upToken string
upToken = XQiniuOss.XClient().SimpleUpload()
Println("Client Upload Token:", upToken)

upToken := XQiniuOss.XClient().OverwriteUpload("keyToOverwrite")
Println("Client Overwrite Upload Token:", upToken)

callbackUploadToken := XQiniuOss.XClient().CallbackUpload()
Println("Client Callback Upload Token:", callbackUploadToken)

2、 服务端断点上传

putRet, err := XQiniuOss.XClient().BreakPointUpload("fileKey", "localFilePath", "recordDir")
So(err, ShouldBeNil)
Println("BreakPointUpload Key:", putRet.Key)
Println("BreakPointUpload PersistentID:", putRet.PersistentID)
Println("BreakPointUpload Hash:", putRet.Hash)

3、服务端表单上传

// 服务器表单上传
putRet1, err := XQiniuOss.XClient().FormUploadWithLocalFile("localFilePath", "fileKey")
So(err, ShouldBeNil)
Println("FormUploadWithLocalFile Key:", putRet1.Key)
Println("FormUploadWithLocalFile PersistentID:", putRet1.PersistentID)
Println("FormUploadWithLocalFile Hash:", putRet1.Hash)

// 服务器字节数组上传
var data []byte
putRet2, err := XQiniuOss.XClient().FormUploadWithByteSlice("fileKey", data)
So(err, ShouldBeNil)
Println("FormUploadWithByteSlice Key:", putRet2.Key)
Println("FormUploadWithByteSlice PersistentID:", putRet2.PersistentID)
Println("FormUploadWithByteSlice Hash:", putRet2.Hash)

4、服务端分块上传

putRet, err := XQiniuOss.XClient().MultipartUpload("localFilePath", "fileKey")
So(err, ShouldBeNil)
Println("MultipartUpload Key:", putRet.Key)
Println("MultipartUpload PersistentID:", putRet.PersistentID)
Println("MultipartUpload Hash:", putRet.Hash)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDefaultClient

func CreateDefaultClient(config *Config)

创建一个默认配置的Manager

func NewStarter

func NewStarter() *starter

func XFClient

func XFClient(f func(c *QnClient) error) error

资源组件闭包执行

Types

type Config

type Config struct {
	AccessKey        string // 开发者key
	SecretKey        string // 开发者secret
	DefaultBucket    string // 存储库名
	ReturnBody       string // 返回信息格式
	UseHTTPS         bool   // 是否使用https域名
	UseCdnDomains    bool   // 上传是否使用CDN上传加速
	UpTokenExpires   int    // 上传凭证有效期
	CallbackURL      string // 上传回调地址
	CallbackBody     string // 上传回调信息格式
	CallbackBodyType string // 上传回调信息格式
	EndUser          string // 唯一宿主标识
	FsizeMin         int    // 限定上传文件大小最小值,单位Byte。
	FsizeMax         int    // 限定上传文件大小最大值,单位Byte。超过限制上传文件大小的最大值会被判为上传失败,返回 413 状态码。
	MimeLimit        string // 限定上传类型
}

func DefaultConfig

func DefaultConfig() *Config

type ProgressRecord

type ProgressRecord struct {
	Progresses []storage.BlkputRet `json:"progresses"`
}

type QnClient

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

func NewQnClient

func NewQnClient(config *Config) *QnClient

func XClient

func XClient() *QnClient

func (*QnClient) BreakPointUpload

func (client *QnClient) BreakPointUpload(fileKey, localFilePath, recordDir string) (storage.PutRet, error)

func (*QnClient) BreakPointUploadToBucket added in v1.2.3

func (client *QnClient) BreakPointUploadToBucket(bucket, fileKey, localFilePath, recordDir string) (storage.PutRet, error)

@param bucket string 指定上传的bucket @param fileKey string 文件唯一key @param localFilePath string 本地文件路径 @param recordKey string 指定的进度文件保存目录,实际情况下,请确保该目录存在,而且只用于记录进度文件

func (*QnClient) CallbackUpload

func (client *QnClient) CallbackUpload() (upToken string)

默认bucket带回调上传,返回上传凭证,给客户端上传

func (*QnClient) CallbackUploadToBucket added in v1.2.3

func (client *QnClient) CallbackUploadToBucket(bucket string) (upToken string)

带回调上传,返回上传凭证,给客户端上传

func (*QnClient) FormUploadWithByteSlice

func (client *QnClient) FormUploadWithByteSlice(fileKey string, data []byte) (storage.PutRet, error)

func (*QnClient) FormUploadWithByteSliceToBucket added in v1.2.3

func (client *QnClient) FormUploadWithByteSliceToBucket(bucket, fileKey string, data []byte) (storage.PutRet, error)

字节数组上传

func (*QnClient) FormUploadWithLocalFile

func (client *QnClient) FormUploadWithLocalFile(fileKey, localFilePath string) (storage.PutRet, error)

func (*QnClient) FormUploadWithLocalFileToBucket added in v1.2.3

func (client *QnClient) FormUploadWithLocalFileToBucket(bucket, fileKey, localFilePath string) (storage.PutRet, error)

表单上传 @param bucket string 指定上传的bucket @param fileKey string 文件唯一key @param localFilePath string 本地文件路径

func (*QnClient) MultipartUpload

func (client *QnClient) MultipartUpload(fileKey, localFilePath string) (storage.PutRet, error)

func (*QnClient) MultipartUploadToBucket added in v1.2.3

func (client *QnClient) MultipartUploadToBucket(bucket, fileKey, localFilePath string) (storage.PutRet, error)

分块上传 @param bucket string 指定上传的bucket @param fileKey string 文件唯一key @param localFilePath string 本地文件路径

func (*QnClient) OverwriteUpload

func (client *QnClient) OverwriteUpload(keyToOverwrite string) (upToken string)

默认bucket覆盖上传,返回上传凭证,给客户端上传

func (*QnClient) OverwriteUploadToBucket added in v1.2.3

func (client *QnClient) OverwriteUploadToBucket(bucket, keyToOverwrite string) (upToken string)

覆盖上传,返回上传凭证,给客户端上传

func (*QnClient) SimpleUpload

func (client *QnClient) SimpleUpload() (upToken string)

默认bucket简单上传,返回上传凭证,给客户端上传

func (*QnClient) SimpleUploadToBucket added in v1.2.3

func (client *QnClient) SimpleUploadToBucket(bucket string) (upToken string)

简单上传,返回上传凭证给客户端上传

Jump to

Keyboard shortcuts

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