Categorygithub.com/yiGmMk/cos-go-sdk-v5
modulepackage
1.0.0
Repository: https://github.com/yigmmk/cos-go-sdk-v5.git
Documentation: pkg.go.dev

# README

cos-go-sdk-v5

腾讯云对象存储服务 COS(Cloud Object Storage) Go SDK(API 版本: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:

数据处理 API:

内容审核 API:

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AddAuthorizationHeader 给 req 增加签名信息.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewAuthTime 生成 AuthTime 的便捷函数 expire: 从现在开始多久过期.
NewBucketURL 生成 BaseURL 所需的 BucketURL bucketName: bucket名称, bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式 Region: 区域代码: ap-beijing-1,ap-beijing,ap-shanghai,ap-guangzhou..
NewClient returns a new COS API client.
非线程安全,只能在进程初始化(而不是Client初始化)时做设置.
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

数据传输完成, 但不能表示对应API调用完成.
数据传输中.
只有在数据传输时发生错误才会返回.
数据开始传输.
Version current go sdk version.

# Variables

需要校验的 Headers 列表.

# Structs

ACLGrant is the param of ACLXml.
ACLGrantee is the param of ACLGrant.
ACLHeaderOptions is the option of ACLHeader.
ACLXml is the ACL body struct.
No description provided by the author
有意和转码区分,两种任务关注的参数不一样避免干扰.
No description provided by the author
AudioAuditingJobConf is the config of PutAudioAuditingJobOptions.
AudioAuditingJobDetail is the detail of GetAudioAuditingJobResult.
AudioSectionResult is the audio section result of AuditingJobDetail/AudioAuditingJobDetail.
AuditingJobDetail is the detail of GetVideoAuditingJobResult.
AuthorizationTransport 给请求增加 Authorization header.
AuthTime 用于生成签名所需的 q-sign-time 和 q-key-time 相关参数.
BaseURL 访问各 API 所需的基础 URL.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BatchImageAuditingJobResult is the result of BatchImageAuditing.
BatchImageAuditingOptions is the option of BatchImageAuditing.
BatchInitiateRestoreObject.
No description provided by the author
No description provided by the author
BatchJobManifest.
No description provided by the author
BatchJobOperation.
No description provided by the author
BatchJobReport.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BatchJobOperationCopy.
No description provided by the author
BatchProgressSummary.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Bucket is the meta info of Bucket.
BucketCORSRule is the rule of BucketCORS.
No description provided by the author
No description provided by the author
BucketGetCORSResult is the result of GetBucketCORS.
BucketGetLifecycleResult is the result of BucketGetLifecycle.
BucketGetLocationResult is the result of BucketGetLocation.
No description provided by the author
No description provided by the author
BucketGetOptions is the option of GetBucket.
BucketGetResult is the result of GetBucket.
BucketGetTaggingResult is the result of BucketGetTagging.
No description provided by the author
BucketInventoryDestination ...
BucketInventoryEncryption ...
BucketInventoryFilter ...
BucketInventoryOptionalFields ...
BucketInventorySchedule ...
BucketLifecycleAbortIncompleteMultipartUpload is the param of BucketLifecycleRule.
No description provided by the author
BucketLifecycleExpiration is the param of BucketLifecycleRule.
BucketLifecycleFilter is the param of BucketLifecycleRule.
No description provided by the author
BucketLifecycleRule is the rule of BucketLifecycle.
BucketLifecycleTransition is the param of BucketLifecycleRule.
BucketLoggingEnabled main struct of logging.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
BucketPutACLOptions is the option of PutBucketACL.
BucketPutCORSOptions is the option of PutBucketCORS.
No description provided by the author
No description provided by the author
No description provided by the author
BucketPutInventoryOptions ...
BucketPutLifecycleOptions is the option of PutBucketLifecycle.
BucketPutLoggingOptions is the options of PutBucketLogging.
BucketPutOptions is same to the ACLHeaderOptions.
No description provided by the author
No description provided by the author
No description provided by the author
BucketPutTaggingOptions is the option of BucketPutTagging.
BucketPutVersionOptions is the options of PutBucketVersioning.
No description provided by the author
BucketReplicationRule is the main param of replication.
No description provided by the author
BucketTaggingTag is the tag of BucketTagging.
CASJobParameters support three way: Standard(in 35 hours), Expedited(quick way, in 15 mins), Bulk(in 5-12 hours_.
No description provided by the author
Client is a client manages communication with the COS API.
No description provided by the author
CompleteMultipartUploadOptions is the option of CompleteMultipartUpload.
CompleteMultipartUploadResult is the result CompleteMultipartUpload.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
CopyPartResult is the result CopyPart.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
DocumentAuditingJobConf is the config of PutDocumentAuditingJobOptions.
DocumentAuditingJobDetail is the detail of GetDocumentAuditingJobResult.
DocumentPageSegmentInfo.
DocumentPageSegmentResultResult.
DocumentResultInfo.
No description provided by the author
No description provided by the author
No description provided by the author
ErrorResponse 包含 API 返回的错误信息 https://www.qcloud.com/document/product/436/7730.
No description provided by the author
No description provided by the author
GetAudioAuditingJobResult is the result of GetAudioAuditingJob.
GetDocumentAuditingJobResult is the result of GetDocumentAuditingJob.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GetTextAuditingJobResult is the result of GetTextAuditingJob.
GetVideoAuditingJobResult is the result of GetVideoAuditingJob.
GetVideoAuditingJobSnapshot is the snapshot result of AuditingJobDetail.
GetWebpageAuditingJobResult is the result of GetWebpageAuditingJob.
No description provided by the author
ImageAuditingInputOptions is the option of BatchImageAuditingOptions.
ImageAuditingJobConf is the config of BatchImageAuditingOptions.
ImageRecognitionResult is the result of BatchImageAuditingJobResult.
No description provided by the author
ImageRecognitionOptions is the option of ImageAuditing.
ImageRecognitionResult is the result of ImageRecognition/ImageAuditing.
InitiateMultipartUploadOptions is the option of InitateMultipartUpload.
InitiateMultipartUploadResult is the result of InitateMultipartUpload.
No description provided by the author
No description provided by the author
jobs.
No description provided by the author
No description provided by the author
LibResult.
No description provided by the author
ListBucketInventoryConfigResult result of ListBucketInventoryConfiguration.
ListMultipartUploadsOptions is the option of ListMultipartUploads.
ListMultipartUploadsResult is the result of ListMultipartUploads.
No description provided by the author
No description provided by the author
No description provided by the author
Location.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
MultiUploadOptions is the option of the multiupload, ThreadPoolSize default is one.
Object is the meta info of the object.
ObjectCopyHeaderOptions is the head option of the Copy.
ObjectCopyOptions is the option of Copy, choose header or body.
ObjectCopyPartOptions is the options of copy-part.
ObjectCopyResult is the result of Copy.
ObjectDeleteMultiOptions is the option of DeleteMulti.
ObjectDeleteMultiResult is the result of DeleteMulti.
No description provided by the author
ObjectGetOptions is the option of GetObject.
ObjectHeadOptions is the option of HeadObject.
ObjectListPartsOptions is the option of ListParts.
ObjectListPartsResult is the result of ListParts.
No description provided by the author
No description provided by the author
ObjectOptionsOptions is the option of object options.
ObjectPutACLOptions the options of put object acl.
ObjectPutHeaderOptions the options of header of the put object.
ObjectPutOptions the options of put object.
No description provided by the author
ObjectRestoreOptions is the option of object restore.
ObjectResult.
No description provided by the author
No description provided by the author
No description provided by the author
ObjectUploadPartOptions is the options of upload-part.
OcrResult.
No description provided by the author
Owner defines Bucket/Object's owner.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PutAudioAuditingJobOptions is the option of PutAudioAuditingJob.
PutBucketReplicationOptions is the options of PutBucketReplication.
PutDocumentAuditingJobOptions is the option of PutDocumentAuditingJob.
No description provided by the author
No description provided by the author
PutTextAuditingJobOptions is the option of PutTextAuditingJob.
PutVideoAuditingJobOptions is the option of PutVideoAuditingJob.
PutVideoAuditingJobResult is the result of PutVideoAuditingJob.
PutVideoAuditingJobSnapshot is the snapshot config of VideoAuditingJobConf.
PutWebpageAuditingJobOptions is the option of PutWebpageAuditingJob.
No description provided by the author
No description provided by the author
RecognitionInfo is the result of auditing scene.
No description provided by the author
ReplicationDestination is the sub struct of BucketReplicationRule.
Response API 响应.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ServiceGetResult is the result of Get Service.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
TextAuditingJobConf is the config of PutAudioAuditingJobOptions.
TextAuditingJobDetail is the detail of GetTextAuditingJobResult.
TextRecognitionInfo.
TextSectionResult is the section result of TextAuditingJobDetail.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
VideoAuditingJobConf is the config of PutVideoAuditingJobOptions.
No description provided by the author
WebpageAuditingJobConf is the config of PutWebpageAuditingJobOptions.
WebpageAuditingJobDetail is the detail of GetWebpageAuditingJobResult.
WebpageImageResult.
WebpageImageResults.
WebpageResultInfo.
WebpageTextResult.
WebpageTextResults.
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author
用户自定义Listener需要实现该方法.

# Type aliases

No description provided by the author
No description provided by the author
BucketGetACLResult is same to the ACLXml.
No description provided by the author
No description provided by the author
No description provided by the author
BucketGetInventoryResult same struct to options.
BucketGetLoggingResult is the result of GetBucketLogging.
No description provided by the author
No description provided by the author
No description provided by the author
BucketGetVersionResult is the result of GetBucketVersioning.
No description provided by the author
BucketListInventoryConfiguartion same struct to options.
BucketService 相关 API.
No description provided by the author
GetBucketReplicationResult is the result of GetBucketReplication.
No description provided by the author
Initiator same to the Owner struct.
ObjectGetACLResult is the result of GetObjectACL.
No description provided by the author
ObjectList can used for sort the parts which needs in complete upload part sort.Sort(cos.ObjectList(opt.Parts)).
ObjectService 相关 API.
No description provided by the author
No description provided by the author
PutAudioAuditingJobResult is the result of PutAudioAuditingJob.
PutDocumentAuditingJobResult is the result of PutDocumentAuditingJob.
PutTextAuditingJobResult is the result of PutTextAuditingJob.
PutWebpageAuditingJobResult is the result of PutWebpageAuditingJob.
Service 相关 API.