You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
小黄 af20914503 newest version 3 years ago
.github/workflows add auto changelog workflow 4 years ago
costesting newest version 3 years ago
crypto newest version 3 years ago
debug solve the oom when send the big file with the debug request header option 5 years ago
.bumpversion.cfg first to commit project 6 years ago
.gitignore add:支持多任务接口 3 years ago
.travis.yml update travis.yml 4 years ago
CHANGELOG.md Updated CHANGELOG.md 3 years ago
LICENSE first to commit project 6 years ago
Makefile 补全object.go, ci.go, ci_doc.go的单元测试 3 years ago
README.md newest version 3 years ago
auth.go add retry options 3 years ago
auth_test.go add retry options 3 years ago
batch.go add ci guetzli && test 3 years ago
batch_test.go update batch 4 years ago
bucket.go update bucket get 3 years ago
bucket_accelerate.go add append && add retry 3 years ago
bucket_accelerate_test.go add append && add retry 3 years ago
bucket_acl.go add append && add retry 3 years ago
bucket_acl_test.go first to commit project 6 years ago
bucket_cors.go add append && add retry 3 years ago
bucket_cors_test.go first to commit project 6 years ago
bucket_domain.go update download retry && bucket domain 3 years ago
bucket_domain_test.go update download retry && bucket domain 3 years ago
bucket_encryption.go add append && add retry 3 years ago
bucket_encryption_test.go 多版本删除 4 years ago
bucket_intelligenttiering.go add append && add retry 3 years ago
bucket_intelligenttiering_test.go add bucket intelligenttiering 4 years ago
bucket_inventory.go add append && add retry 3 years ago
bucket_inventory_test.go update bucket inventory/logging/replication/versioning/tagging and test 4 years ago
bucket_lifecycle.go update context 3 years ago
bucket_lifecycle_test.go update bucket lifecycle 3 years ago
bucket_location.go update the comment for godoc 6 years ago
bucket_location_test.go first to commit project 6 years ago
bucket_logging.go add append && add retry 3 years ago
bucket_logging_test.go update bucket inventory/logging/replication/versioning/tagging and test 4 years ago
bucket_origin.go add append && add retry 3 years ago
bucket_origin_test.go add ci guetzli && test 3 years ago
bucket_part.go update the comment for godoc 6 years ago
bucket_part_test.go first to commit project 6 years ago
bucket_policy.go add append && add retry 3 years ago
bucket_policy_test.go add ci guetzli && test 3 years ago
bucket_referer.go add append && add retry 3 years ago
bucket_referer_test.go add encryption and referer 4 years ago
bucket_replication.go add append && add retry 3 years ago
bucket_replication_test.go update bucket inventory/logging/replication/versioning/tagging and test 4 years ago
bucket_tagging.go add append && add retry 3 years ago
bucket_tagging_test.go first to commit project 6 years ago
bucket_test.go add ci doc 3 years ago
bucket_version.go add append && add retry 3 years ago
bucket_version_test.go update bucket inventory/logging/replication/versioning/tagging and test 4 years ago
bucket_website.go add append && add retry 3 years ago
bucket_website_test.go update bucket domain and website struct 5 years ago
ci.go 内容审核六期接口 3 years ago
ci_doc.go add CI QRCode && Update CI 3 years ago
ci_doc_test.go add append && add retry 3 years ago
ci_media.go add CI 媒体处理接口 3 years ago
ci_media_test.go add append && add retry 3 years ago
ci_test.go add append && add retry 3 years ago
cos.go add retry options 3 years ago
cos_test.go add fetch task api && add cvm role 3 years ago
doc.go fix content 6 years ago
error.go add fetch task api && add cvm role 3 years ago
error_test.go add append && add retry 3 years ago
go.mod newest version 3 years ago
go.sum newest version 3 years ago
helper.go add append && add retry 3 years ago
helper_test.go add Crypto UserAgent and versionid 3 years ago
object.go add fetch task api && add cvm role 3 years ago
object_acl.go add append && add retry 3 years ago
object_acl_test.go first to commit project 6 years ago
object_part.go add append && add retry 3 years ago
object_part_test.go latest 0.7.23 stable 3 years ago
object_select.go update bucket lifecycle 3 years ago
object_test.go add retry options 3 years ago
progress.go add append && add retry 3 years ago
service.go update the comment for godoc 6 years ago
service_test.go add ci doc 3 years ago

README.md

cos-go-sdk-v5

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

Install

go get -u git.ouxuan.net/tommy/cos-go-sdk-v5

Usage

package main

import (
	"context"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"os"
	"time"
	
	"git.ouxuan.net/tommy/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:

数据处理 API:

内容审核 API: