terraform/vendor/github.com/tencentyun/cos-go-sdk-v5
Li Kexian 76e5b446ba
backend/cos: Add TencentCloud backend cos with lock (#22540)
* add TencentCloud COS backend for remote state

* add vendor of dependence

* fixed error not handle and remove default value for prefix argument

* get appid from TF_COS_APPID environment variables
2020-02-13 11:37:11 -05:00
..
.bumpversion.cfg backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
.gitignore backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
.travis.yml backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
LICENSE backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
Makefile backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
README.md backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
auth.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_acl.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_cors.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_inventory.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_lifecycle.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_location.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_logging.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_part.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_replication.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_tagging.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
bucket_version.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
cos.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
doc.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
error.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
go.mod backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
go.sum backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
helper.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
object.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
object_acl.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
object_part.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00
service.go backend/cos: Add TencentCloud backend cos with lock (#22540) 2020-02-13 11:37:11 -05:00

README.md

cos-go-sdk-v5

腾讯云对象存储服务 COS(Cloud Object Storage) Go SDKAPI 版本V5 版本的 XML API

Install

go get -u github.com/tencentyun/cos-go-sdk-v5

Usage

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"os"
	"time"
	
	"github.com/tencentyun/cos-go-sdk-v5"
)

func main() {
	//将<bucket>和<region>修改为真实的信息
	//bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式
	u, _ := url.Parse("https://<bucket>.cos.<region>.myqcloud.com")
	b := &cos.BaseURL{BucketURL: u}
	c := cos.NewClient(b, &http.Client{
		//设置超时时间
		Timeout: 100 * time.Second,
		Transport: &cos.AuthorizationTransport{
			//如实填写账号和密钥,也可以设置为环境变量
			SecretID:  os.Getenv("COS_SECRETID"),
			SecretKey: os.Getenv("COS_SECRETKEY"),
		},
	})

	name := "test/hello.txt"
	resp, err := c.Object.Get(context.Background(), name, nil)
	if err != nil {
		panic(err)
	}
	bs, _ := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	fmt.Printf("%s\n", string(bs))
}

所有的 API 在 example 目录下都有对应的使用示例。

Service API:

Bucket API:

Object API: