qcloud

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAuthorizationHeader

func AddAuthorizationHeader(secretID, secretKey string, sessionToken string, req *http.Request, authTime *AuthTime)

AddAuthorizationHeader 给 req 增加签名信息

func NewAuthorization

func NewAuthorization(secretID, secretKey string, req *http.Request, authTime *AuthTime) string

newAuthorization 通过一系列步骤生成最终需要的 Authorization 字符串

Types

type AuthTime

type AuthTime struct {
	SignStartTime time.Time
	SignEndTime   time.Time
	KeyStartTime  time.Time
	KeyEndTime    time.Time
}

AuthTime 用于生成签名所需的 q-sign-time 和 q-key-time 相关参数

func NewAuthTime

func NewAuthTime(expire time.Duration) *AuthTime

NewAuthTime 生成 AuthTime 的便捷函数

expire: 从现在开始多久过期.

type AuthorizationTransport

type AuthorizationTransport struct {
	SecretID     string
	SecretKey    string
	SessionToken string

	// 签名多久过期
	Expire    time.Duration
	Transport http.RoundTripper
	// contains filtered or unexported fields
}

AuthorizationTransport 给请求增加 Authorization header

func (*AuthorizationTransport) GetCredential

func (t *AuthorizationTransport) GetCredential() (string, string, string)

GetCredential get the ak, sk, token

func (*AuthorizationTransport) SetCredential

func (t *AuthorizationTransport) SetCredential(ak, sk, token string)

SetCredential update the SecretID(ak), SercretKey(sk), sessiontoken

type Config

type Config struct {
	AppId         string // 腾讯云appId
	SecretId      string // 腾讯云secretId
	SecretKey     string // 腾讯云secretKey
	COSSubPath    string // 腾讯云对象存储子目录名
	COSBucketName string // 腾讯云对象存储桶名
	COSRegion     string // 腾讯云对象存储区域名
	COSDomain     string // 腾讯云对象存储资源访问域名,如自定义COS访问域名,或自定义COS的DNS访问域名,腾讯云也提供默认访问域名,如下:

}

腾讯云配置对象,以下任何一项为空时,都会尝试取配置文件中的配置,如果配置文件没配置会采用代码中写的默认配置值

type Proxy

type Proxy struct {
	Config
}

func NewProxy

func NewProxy(config *Config) *Proxy

func (*Proxy) PutFile

func (p *Proxy) PutFile(ctxt context.Context, localFileName string) (string, error)

腾讯云对象存储上传文件

Jump to

Keyboard shortcuts

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