terraform/vendor/github.com/tencentyun/cos-go-sdk-v5/README.md

96 lines
4.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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
```go
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](./example/) 目录下都有对应的使用示例。
Service API:
* [x] Get Service使用示例[service/get.go](./example/service/get.go)
Bucket API:
* [x] Get Bucket使用示例[bucket/get.go](./example/bucket/get.go)
* [x] Get Bucket ACL使用示例[bucket/getACL.go](./example/bucket/getACL.go)
* [x] Get Bucket CORS使用示例[bucket/getCORS.go](./example/bucket/getCORS.go)
* [x] Get Bucket Location使用示例[bucket/getLocation.go](./example/bucket/getLocation.go)
* [x] Get Buket Lifecycle使用示例[bucket/getLifecycle.go](./example/bucket/getLifecycle.go)
* [x] Get Bucket Tagging使用示例[bucket/getTagging.go](./example/bucket/getTagging.go)
* [x] Put Bucket使用示例[bucket/put.go](./example/bucket/put.go)
* [x] Put Bucket ACL使用示例[bucket/putACL.go](./example/bucket/putACL.go)
* [x] Put Bucket CORS使用示例[bucket/putCORS.go](./example/bucket/putCORS.go)
* [x] Put Bucket Lifecycle使用示例[bucket/putLifecycle.go](./example/bucket/putLifecycle.go)
* [x] Put Bucket Tagging使用示例[bucket/putTagging.go](./example/bucket/putTagging.go)
* [x] Delete Bucket使用示例[bucket/delete.go](./example/bucket/delete.go)
* [x] Delete Bucket CORS使用示例[bucket/deleteCORS.go](./example/bucket/deleteCORS.go)
* [x] Delete Bucket Lifecycle使用示例[bucket/deleteLifecycle.go](./example/bucket/deleteLifecycle.go)
* [x] Delete Bucket Tagging使用示例[bucket/deleteTagging.go](./example/bucket/deleteTagging.go)
* [x] Head Bucket使用示例[bucket/head.go](./example/bucket/head.go)
* [x] List Multipart Uploads使用示例[bucket/listMultipartUploads.go](./example/bucket/listMultipartUploads.go)
Object API:
* [x] Get Object使用示例[object/get.go](./example/object/get.go)
* [x] Get Object ACL使用示例[object/getACL.go](./example/object/getACL.go)
* [x] Put Object使用示例[object/put.go](./example/object/put.go)
* [x] Put Object ACL使用示例[object/putACL.go](./example/object/putACL.go)
* [x] Put Object Copy使用示例[object/copy.go](./example/object/copy.go)
* [x] Delete Object使用示例[object/delete.go](./example/object/delete.go)
* [x] Delete Multiple Object使用示例[object/deleteMultiple.go](./example/object/deleteMultiple.go)
* [x] Head Object使用示例[object/head.go](./example/object/head.go)
* [x] Options Object使用示例[object/options.go](./example/object/options.go)
* [x] Initiate Multipart Upload使用示例[object/initiateMultipartUpload.go](./example/object/initiateMultipartUpload.go)
* [x] Upload Part使用示例[object/uploadPart.go](./example/object/uploadPart.go)
* [x] List Parts使用示例[object/listParts.go](./example/object/listParts.go)
* [x] Complete Multipart Upload使用示例[object/completeMultipartUpload.go](./example/object/completeMultipartUpload.go)
* [x] Abort Multipart Upload使用示例[object/abortMultipartUpload.go](./example/object/abortMultipartUpload.go)
* [x] Mutipart Upload使用示例[object/MutiUpload.go](./example/object/MutiUpload.go)