cos

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: MIT Imports: 24 Imported by: 0

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:

Documentation

Overview

Package cos is COS(Cloud Object Storage) Go SDK. The V5 version(XML API). There are examples of using each API in the project's 'example' directory.

Index

Constants

View Source
const (
	// Version current go sdk version
	Version = "0.7.3"
)

Variables

This section is empty.

Functions

func AddAuthorizationHeader

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

AddAuthorizationHeader 给 req 增加签名信息

func DividePart

func DividePart(fileSize int64) (int64, int64)

func NewBucketURL

func NewBucketURL(bucketName, region string, secure bool) *url.URL

NewBucketURL 生成 BaseURL 所需的 BucketURL

bucketName: bucket名称, bucket的命名规则为{name}-{appid} ,此处填写的存储桶名称必须为此格式
Region: 区域代码: ap-beijing-1,ap-beijing,ap-shanghai,ap-guangzhou...
secure: 是否使用 https

Types

type ACLGrant

type ACLGrant struct {
	Grantee    *ACLGrantee
	Permission string
}

ACLGrant is the param of ACLXml

type ACLGrantee

type ACLGrantee struct {
	Type        string `xml:"type,attr"`
	UIN         string `xml:"uin,omitempty"`
	URI         string `xml:"URI,omitempty"`
	ID          string `xml:",omitempty"`
	DisplayName string `xml:",omitempty"`
	SubAccount  string `xml:"Subaccount,omitempty"`
}

ACLGrantee is the param of ACLGrant

type ACLHeaderOptions

type ACLHeaderOptions struct {
	XCosACL              string `header:"x-cos-acl,omitempty" url:"-" xml:"-"`
	XCosGrantRead        string `header:"x-cos-grant-read,omitempty" url:"-" xml:"-"`
	XCosGrantWrite       string `header:"x-cos-grant-write,omitempty" url:"-" xml:"-"`
	XCosGrantFullControl string `header:"x-cos-grant-full-control,omitempty" url:"-" xml:"-"`
}

ACLHeaderOptions is the option of ACLHeader

type ACLXml

type ACLXml struct {
	XMLName           xml.Name `xml:"AccessControlPolicy"`
	Owner             *Owner
	AccessControlList []ACLGrant `xml:"AccessControlList>Grant,omitempty"`
}

ACLXml is the ACL body struct

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) RoundTrip

func (t *AuthorizationTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

func (*AuthorizationTransport) SetCredential

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

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

type BaseURL

type BaseURL struct {
	// 访问 bucket, object 相关 API 的基础 URL(不包含 path 部分): http://example.com
	BucketURL *url.URL
	// 访问 service API 的基础 URL(不包含 path 部分): http://example.com
	ServiceURL *url.URL
	// 访问 job API 的基础 URL (不包含 path 部分): http://example.com
	BatchURL *url.URL
}

BaseURL 访问各 API 所需的基础 URL

type BatchAccessControlGrants

type BatchAccessControlGrants struct {
	COSGrants *BatchCOSGrant `xml:"COSGrant,omitempty" header:"-" url:"-"`
}

type BatchCOSGrant

type BatchCOSGrant struct {
	Grantee    *BatchGrantee `xml:"Grantee" header:"-" url:"-"`
	Permission string        `xml:"Permission" header:"-" url:"-"`
}

type BatchCreateJobOptions

type BatchCreateJobOptions struct {
	XMLName              xml.Name           `xml:"CreateJobRequest" header:"-" url:"-"`
	ClientRequestToken   string             `xml:"ClientRequestToken" header:"-" url:"-"`
	ConfirmationRequired string             `xml:"ConfirmationRequired,omitempty" header:"-" url:"-"`
	Description          string             `xml:"Description,omitempty" header:"-" url:"-"`
	Manifest             *BatchJobManifest  `xml:"Manifest" header:"-" url:"-"`
	Operation            *BatchJobOperation `xml:"Operation" header:"-" url:"-"`
	Priority             int                `xml:"Priority" header:"-" url:"-"`
	Report               *BatchJobReport    `xml:"Report" header:"-" url:"-"`
	RoleArn              string             `xml:"RoleArn" header:"-" url:"-"`
}

type BatchCreateJobResult

type BatchCreateJobResult struct {
	XMLName xml.Name `xml:"CreateJobResult"`
	JobId   string   `xml:"JobId,omitempty"`
}

type BatchDescribeJob

type BatchDescribeJob struct {
	ConfirmationRequired string                  `xml:"ConfirmationRequired,omitempty" header:"-" url:"-"`
	CreationTime         string                  `xml:"CreationTime,omitempty" header:"-" url:"-"`
	Description          string                  `xml:"Description,omitempty" header:"-" url:"-"`
	FailureReasons       *BatchJobFailureReasons `xml:"FailureReasons>JobFailure,omitempty" header:"-" url:"-"`
	JobId                string                  `xml:"JobId" header:"-" url:"-"`
	Manifest             *BatchJobManifest       `xml:"Manifest" header:"-" url:"-"`
	Operation            *BatchJobOperation      `xml:"Operation" header:"-" url:"-"`
	Priority             int                     `xml:"Priority" header:"-" url:"-"`
	ProgressSummary      *BatchProgressSummary   `xml:"ProgressSummary" header:"-" url:"-"`
	Report               *BatchJobReport         `xml:"Report,omitempty" header:"-" url:"-"`
	RoleArn              string                  `xml:"RoleArn,omitempty" header:"-" url:"-"`
	Status               string                  `xml:"Status,omitempty" header:"-" url:"-"`
	StatusUpdateReason   string                  `xml:"StatusUpdateReason,omitempty" header:"-" url:"-"`
	SuspendedCause       string                  `xml:"SuspendedCause,omitempty" header:"-" url:"-"`
	SuspendedDate        string                  `xml:"SuspendedDate,omitempty" header:"-" url:"-"`
	TerminationDate      string                  `xml:"TerminationDate,omitempty" header:"-" url:"-"`
}

type BatchDescribeJobResult

type BatchDescribeJobResult struct {
	XMLName xml.Name          `xml:"DescribeJobResult"`
	Job     *BatchDescribeJob `xml:"Job,omitempty"`
}

type BatchGrantee

type BatchGrantee struct {
	DisplayName    string `xml:"DisplayName,omitempty" header:"-" url:"-"`
	Identifier     string `xml:"Identifier" header:"-" url:"-"`
	TypeIdentifier string `xml:"TypeIdentifier" header:"-" url:"-"`
}

type BatchInitiateRestoreObject

type BatchInitiateRestoreObject struct {
	ExpirationInDays int    `xml:"ExpirationInDays"`
	JobTier          string `xml:"JobTier"`
}

BatchInitiateRestoreObject

type BatchJobFailureReasons

type BatchJobFailureReasons struct {
	FailureCode   string `xml:"FailureCode" header:"-" url:"-"`
	FailureReason string `xml:"FailureReason" header:"-" url:"-"`
}

type BatchJobManifest

type BatchJobManifest struct {
	Location *BatchJobManifestLocation `xml:"Location" header:"-" url:"-"`
	Spec     *BatchJobManifestSpec     `xml:"Spec" header:"-" url:"-"`
}

type BatchJobManifestLocation

type BatchJobManifestLocation struct {
	ETag            string `xml:"ETag" header:"-" url:"-"`
	ObjectArn       string `xml:"ObjectArn" header:"-" url:"-"`
	ObjectVersionId string `xml:"ObjectVersionId,omitempty" header:"-" url:"-"`
}

BatchJobManifest

type BatchJobManifestSpec

type BatchJobManifestSpec struct {
	Fields []string `xml:"Fields>member,omitempty" header:"-" url:"-"`
	Format string   `xml:"Format" header:"-" url:"-"`
}

type BatchJobOperation

type BatchJobOperation struct {
	PutObjectCopy *BatchJobOperationCopy      `xml:"COSPutObjectCopy,omitempty" header:"-" url:"-"`
	RestoreObject *BatchInitiateRestoreObject `xml:"COSInitiateRestoreObject,omitempty" header:"-" url:"-"`
}

BatchJobOperation

type BatchJobOperationCopy

type BatchJobOperationCopy struct {
	AccessControlGrants       *BatchAccessControlGrants `xml:"AccessControlGrants,omitempty" header:"-" url:"-"`
	CannedAccessControlList   string                    `xml:"CannedAccessControlList,omitempty" header:"-" url:"-"`
	MetadataDirective         string                    `xml:"MetadataDirective,omitempty" header:"-" url:"-"`
	ModifiedSinceConstraint   int64                     `xml:"ModifiedSinceConstraint,omitempty" header:"-" url:"-"`
	UnModifiedSinceConstraint int64                     `xml:"UnModifiedSinceConstraint,omitempty" header:"-" url:"-"`
	NewObjectMetadata         *BatchNewObjectMetadata   `xml:"NewObjectMetadata,omitempty" header:"-" url:"-"`
	StorageClass              string                    `xml:"StorageClass,omitempty" header:"-" url:"-"`
	TargetResource            string                    `xml:"TargetResource" header:"-" url:"-"`
}

type BatchJobReport

type BatchJobReport struct {
	Bucket      string `xml:"Bucket" header:"-" url:"-"`
	Enabled     string `xml:"Enabled" header:"-" url:"-"`
	Format      string `xml:"Format" header:"-" url:"-"`
	Prefix      string `xml:"Prefix,omitempty" header:"-" url:"-"`
	ReportScope string `xml:"ReportScope" header:"-" url:"-"`
}

BatchJobReport

type BatchListJobs

type BatchListJobs struct {
	Members []BatchListJobsMember `xml:"member,omitempty" header:"-" url:"-"`
}

type BatchListJobsMember

type BatchListJobsMember struct {
	CreationTime    string                `xml:"CreationTime,omitempty" header:"-" url:"-"`
	Description     string                `xml:"Description,omitempty" header:"-" url:"-"`
	JobId           string                `xml:"JobId,omitempty" header:"-" url:"-"`
	Operation       string                `xml:"Operation,omitempty" header:"-" url:"-"`
	Priority        int                   `xml:"Priority,omitempty" header:"-" url:"-"`
	ProgressSummary *BatchProgressSummary `xml:"ProgressSummary,omitempty" header:"-" url:"-"`
	Status          string                `xml:"Status,omitempty" header:"-" url:"-"`
	TerminationDate string                `xml:"TerminationDate,omitempty" header:"-" url:"-"`
}

type BatchListJobsOptions

type BatchListJobsOptions struct {
	JobStatuses string `url:"jobStatuses,omitempty" header:"-" xml:"-"`
	MaxResults  int    `url:"maxResults,omitempty" header:"-" xml:"-"`
	NextToken   string `url:"nextToken,omitempty" header:"-" xml:"-"`
}

type BatchListJobsResult

type BatchListJobsResult struct {
	XMLName   xml.Name       `xml:"ListJobsResult"`
	Jobs      *BatchListJobs `xml:"Jobs,omitempty"`
	NextToken string         `xml:"NextToken,omitempty"`
}

type BatchMetadata

type BatchMetadata struct {
	Key   string `xml:"Key" header:"-" url:"-"`
	Value string `xml:"Value" header:"-" url:"-"`
}

BatchJobOperationCopy

type BatchNewObjectMetadata

type BatchNewObjectMetadata struct {
	CacheControl       string          `xml:"CacheControl,omitempty" header:"-" url:"-"`
	ContentDisposition string          `xml:"ContentDisposition,omitempty" header:"-" url:"-"`
	ContentEncoding    string          `xml:"ContentEncoding,omitempty" header:"-" url:"-"`
	ContentType        string          `xml:"ContentType,omitempty" header:"-" url:"-"`
	HttpExpiresDate    string          `xml:"HttpExpiresDate,omitempty" header:"-" url:"-"`
	SSEAlgorithm       string          `xml:"SSEAlgorithm,omitempty" header:"-" url:"-"`
	UserMetadata       []BatchMetadata `xml:"UserMetadata>member,omitempty" header:"-" url:"-"`
}

type BatchProgressSummary

type BatchProgressSummary struct {
	NumberOfTasksFailed    int `xml:"NumberOfTasksFailed" header:"-" url:"-"`
	NumberOfTasksSucceeded int `xml:"NumberOfTasksSucceeded" header:"-" url:"-"`
	TotalNumberOfTasks     int `xml:"TotalNumberOfTasks" header:"-" url:"-"`
}

BatchProgressSummary

type BatchRequestHeaders

type BatchRequestHeaders struct {
	XCosAppid     int          `header:"x-cos-appid" xml:"-" url:"-"`
	ContentLength string       `header:"Content-Length,omitempty" xml:"-" url:"-"`
	ContentType   string       `header:"Content-Type,omitempty" xml:"-" url:"-"`
	Headers       *http.Header `header:"-" xml:"-", url:"-"`
}

type BatchService

type BatchService service

func (*BatchService) CreateJob

func (*BatchService) DescribeJob

func (*BatchService) ListJobs

func (*BatchService) UpdateJobPriority

func (*BatchService) UpdateJobStatus

type BatchUpdatePriorityOptions

type BatchUpdatePriorityOptions struct {
	JobId    string `url:"-" header:"-" xml:"-"`
	Priority int    `url:"priority" header:"-" xml:"-"`
}

type BatchUpdatePriorityResult

type BatchUpdatePriorityResult struct {
	XMLName  xml.Name `xml:"UpdateJobPriorityResult"`
	JobId    string   `xml:"JobId,omitempty"`
	Priority int      `xml:"Priority,omitempty"`
}

type BatchUpdateStatusOptions

type BatchUpdateStatusOptions struct {
	JobId              string `header:"-" url:"-" xml:"-"`
	RequestedJobStatus string `url:"requestedJobStatus" header:"-" xml:"-"`
	StatusUpdateReason string `url:"statusUpdateReason,omitempty" header:"-", xml:"-"`
}

type BatchUpdateStatusResult

type BatchUpdateStatusResult struct {
	XMLName            xml.Name `xml:"UpdateJobStatusResult"`
	JobId              string   `xml:"JobId,omitempty"`
	Status             string   `xml:"Status,omitempty"`
	StatusUpdateReason string   `xml:"StatusUpdateReason,omitempty"`
}

type Bucket

type Bucket struct {
	Name         string
	Region       string `xml:"Location,omitempty"`
	CreationDate string `xml:",omitempty"`
}

Bucket is the meta info of Bucket

type BucketCORSRule

type BucketCORSRule struct {
	ID             string   `xml:"ID,omitempty"`
	AllowedMethods []string `xml:"AllowedMethod"`
	AllowedOrigins []string `xml:"AllowedOrigin"`
	AllowedHeaders []string `xml:"AllowedHeader,omitempty"`
	MaxAgeSeconds  int      `xml:"MaxAgeSeconds,omitempty"`
	ExposeHeaders  []string `xml:"ExposeHeader,omitempty"`
}

BucketCORSRule is the rule of BucketCORS

type BucketGetACLResult

type BucketGetACLResult ACLXml

BucketGetACLResult is same to the ACLXml

type BucketGetCORSResult

type BucketGetCORSResult struct {
	XMLName xml.Name         `xml:"CORSConfiguration"`
	Rules   []BucketCORSRule `xml:"CORSRule,omitempty"`
}

BucketGetCORSResult is the result of GetBucketCORS

type BucketGetDomainResult

type BucketGetDomainResult BucketPutDomainOptions

type BucketGetInventoryResult

type BucketGetInventoryResult BucketPutInventoryOptions

BucketGetInventoryResult same struct to options

type BucketGetLifecycleResult

type BucketGetLifecycleResult struct {
	XMLName xml.Name              `xml:"LifecycleConfiguration"`
	Rules   []BucketLifecycleRule `xml:"Rule,omitempty"`
}

BucketGetLifecycleResult is the result of BucketGetLifecycle

type BucketGetLocationResult

type BucketGetLocationResult struct {
	XMLName  xml.Name `xml:"LocationConstraint"`
	Location string   `xml:",chardata"`
}

BucketGetLocationResult is the result of BucketGetLocation

type BucketGetLoggingResult

type BucketGetLoggingResult BucketPutLoggingOptions

BucketGetLoggingResult is the result of GetBucketLogging

type BucketGetOptions

type BucketGetOptions struct {
	Prefix       string `url:"prefix,omitempty"`
	Delimiter    string `url:"delimiter,omitempty"`
	EncodingType string `url:"encoding-type,omitempty"`
	Marker       string `url:"marker,omitempty"`
	MaxKeys      int    `url:"max-keys,omitempty"`
}

BucketGetOptions is the option of GetBucket

type BucketGetResult

type BucketGetResult struct {
	XMLName        xml.Name `xml:"ListBucketResult"`
	Name           string
	Prefix         string `xml:"Prefix,omitempty"`
	Marker         string `xml:"Marker,omitempty"`
	NextMarker     string `xml:"NextMarker,omitempty"`
	Delimiter      string `xml:"Delimiter,omitempty"`
	MaxKeys        int
	IsTruncated    bool
	Contents       []Object `xml:"Contents,omitempty"`
	CommonPrefixes []string `xml:"CommonPrefixes>Prefix,omitempty"`
	EncodingType   string   `xml:"Encoding-Type,omitempty"`
}

BucketGetResult is the result of GetBucket

type BucketGetTaggingResult

type BucketGetTaggingResult struct {
	XMLName xml.Name           `xml:"Tagging"`
	TagSet  []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
}

BucketGetTaggingResult is the result of BucketGetTagging

type BucketGetVersionResult

type BucketGetVersionResult BucketPutVersionOptions

BucketGetVersionResult is the result of GetBucketVersioning

type BucketGetWebsiteResult

type BucketGetWebsiteResult BucketPutWebsiteOptions

type BucketInventoryDestination

type BucketInventoryDestination struct {
	Bucket     string                     `xml:"Bucket"`
	AccountId  string                     `xml:"AccountId,omitempty"`
	Prefix     string                     `xml:"Prefix,omitempty"`
	Format     string                     `xml:"Format"`
	Encryption *BucketInventoryEncryption `xml:"Encryption,omitempty"`
}

BucketInventoryDestination ...

type BucketInventoryEncryption

type BucketInventoryEncryption struct {
	SSECOS string `xml:"SSE-COS"`
}

BucketInventoryEncryption ...

type BucketInventoryFilter

type BucketInventoryFilter struct {
	Prefix string `xml:"Prefix,omitempty"`
}

BucketInventoryFilter ...

type BucketInventoryOptionalFields

type BucketInventoryOptionalFields struct {
	BucketInventoryFields []string `xml:"Field,omitempty"`
}

BucketInventoryOptionalFields ...

type BucketInventorySchedule

type BucketInventorySchedule struct {
	Frequency string `xml:"Frequency"`
}

BucketInventorySchedule ...

type BucketLifecycleAbortIncompleteMultipartUpload

type BucketLifecycleAbortIncompleteMultipartUpload struct {
	DaysAfterInitiation string `xml:"DaysAfterInititation,omitempty"`
}

BucketLifecycleAbortIncompleteMultipartUpload is the param of BucketLifecycleRule

type BucketLifecycleExpiration

type BucketLifecycleExpiration struct {
	Date string `xml:"Date,omitempty"`
	Days int    `xml:"Days,omitempty"`
}

BucketLifecycleExpiration is the param of BucketLifecycleRule

type BucketLifecycleFilter

type BucketLifecycleFilter struct {
	Prefix string `xml:"Prefix,omitempty"`
}

BucketLifecycleFilter is the param of BucketLifecycleRule

type BucketLifecycleRule

type BucketLifecycleRule struct {
	ID                             string `xml:"ID,omitempty"`
	Status                         string
	Filter                         *BucketLifecycleFilter                         `xml:"Filter,omitempty"`
	Transition                     *BucketLifecycleTransition                     `xml:"Transition,omitempty"`
	Expiration                     *BucketLifecycleExpiration                     `xml:"Expiration,omitempty"`
	AbortIncompleteMultipartUpload *BucketLifecycleAbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
}

BucketLifecycleRule is the rule of BucketLifecycle

type BucketLifecycleTransition

type BucketLifecycleTransition struct {
	Date         string `xml:"Date,omitempty"`
	Days         int    `xml:"Days,omitempty"`
	StorageClass string
}

BucketLifecycleTransition is the param of BucketLifecycleRule

type BucketListInventoryConfiguartion

type BucketListInventoryConfiguartion BucketPutInventoryOptions

BucketListInventoryConfiguartion same struct to options

type BucketLoggingEnabled

type BucketLoggingEnabled struct {
	TargetBucket string `xml:"TargetBucket"`
	TargetPrefix string `xml:"TargetPrefix"`
}

BucketLoggingEnabled main struct of logging

type BucketPutACLOptions

type BucketPutACLOptions struct {
	Header *ACLHeaderOptions `url:"-" xml:"-"`
	Body   *ACLXml           `url:"-" header:"-"`
}

BucketPutACLOptions is the option of PutBucketACL

type BucketPutCORSOptions

type BucketPutCORSOptions struct {
	XMLName xml.Name         `xml:"CORSConfiguration"`
	Rules   []BucketCORSRule `xml:"CORSRule,omitempty"`
}

BucketPutCORSOptions is the option of PutBucketCORS

type BucketPutDomainOptions

type BucketPutDomainOptions struct {
	XMLName           xml.Name `xml:"DomainConfiguration"`
	Status            string   `xml:"DomainRule>Status"`
	Name              string   `xml:"DomainRule>Name"`
	Type              string   `xml:"DomainRule>Type"`
	ForcedReplacement string   `xml:"DomainRule>ForcedReplacement,omitempty"`
}

type BucketPutInventoryOptions

type BucketPutInventoryOptions struct {
	XMLName                xml.Name                       `xml:"InventoryConfiguration"`
	ID                     string                         `xml:"Id"`
	IsEnabled              string                         `xml:"IsEnabled"`
	IncludedObjectVersions string                         `xml:"IncludedObjectVersions"`
	Filter                 *BucketInventoryFilter         `xml:"Filter,omitempty"`
	OptionalFields         *BucketInventoryOptionalFields `xml:"OptionalFields,omitempty"`
	Schedule               *BucketInventorySchedule       `xml:"Schedule"`
	Destination            *BucketInventoryDestination    `xml:"Destination>COSBucketDestination"`
}

BucketPutInventoryOptions ...

type BucketPutLifecycleOptions

type BucketPutLifecycleOptions struct {
	XMLName xml.Name              `xml:"LifecycleConfiguration"`
	Rules   []BucketLifecycleRule `xml:"Rule,omitempty"`
}

BucketPutLifecycleOptions is the option of PutBucketLifecycle

type BucketPutLoggingOptions

type BucketPutLoggingOptions struct {
	XMLName        xml.Name              `xml:"BucketLoggingStatus"`
	LoggingEnabled *BucketLoggingEnabled `xml:"LoggingEnabled,omitempty"`
}

BucketPutLoggingOptions is the options of PutBucketLogging

type BucketPutOptions

type BucketPutOptions ACLHeaderOptions

BucketPutOptions is same to the ACLHeaderOptions

type BucketPutTaggingOptions

type BucketPutTaggingOptions struct {
	XMLName xml.Name           `xml:"Tagging"`
	TagSet  []BucketTaggingTag `xml:"TagSet>Tag,omitempty"`
}

BucketPutTaggingOptions is the option of BucketPutTagging

type BucketPutVersionOptions

type BucketPutVersionOptions struct {
	XMLName xml.Name `xml:"VersioningConfiguration"`
	Status  string   `xml:"Status"`
}

BucketPutVersionOptions is the options of PutBucketVersioning

type BucketPutWebsiteOptions

type BucketPutWebsiteOptions struct {
	XMLName          xml.Name                  `xml:"WebsiteConfiguration"`
	Index            string                    `xml:"IndexDocument>Suffix"`
	RedirectProtocol *RedirectRequestsProtocol `xml:"RedirectAllRequestsTo,omitempty"`
	Error            *ErrorDocument            `xml:"ErrorDocument,omitempty"`
	RoutingRules     *WebsiteRoutingRules      `xml:"RoutingRules,omitempty"`
}

type BucketReplicationRule

type BucketReplicationRule struct {
	ID          string                  `xml:"ID,omitempty"`
	Status      string                  `xml:"Status"`
	Prefix      string                  `xml:"Prefix"`
	Destination *ReplicationDestination `xml:"Destination"`
}

BucketReplicationRule is the main param of replication

type BucketService

type BucketService service

BucketService 相关 API

func (*BucketService) Delete

func (s *BucketService) Delete(ctx context.Context) (*Response, error)

Delete Bucket请求可以在指定账号下删除Bucket,删除之前要求Bucket为空。

https://www.qcloud.com/document/product/436/7732

func (*BucketService) DeleteBucketReplication

func (s *BucketService) DeleteBucketReplication(ctx context.Context) (*Response, error)

DeleteBucketReplication https://cloud.tencent.com/document/product/436/19221

func (*BucketService) DeleteCORS

func (s *BucketService) DeleteCORS(ctx context.Context) (*Response, error)

DeleteCORS 实现 Bucket 跨域访问配置删除。

https://www.qcloud.com/document/product/436/8283

func (*BucketService) DeleteInventory

func (s *BucketService) DeleteInventory(ctx context.Context, id string) (*Response, error)

DeleteBucketInventory https://cloud.tencent.com/document/product/436/33704

func (*BucketService) DeleteLifecycle

func (s *BucketService) DeleteLifecycle(ctx context.Context) (*Response, error)

DeleteLifecycle 请求实现删除生命周期管理。 https://www.qcloud.com/document/product/436/8284

func (*BucketService) DeleteTagging

func (s *BucketService) DeleteTagging(ctx context.Context) (*Response, error)

DeleteTagging 接口实现删除指定Bucket的标签。

https://www.qcloud.com/document/product/436/8286

func (*BucketService) DeleteWebsite

func (s *BucketService) DeleteWebsite(ctx context.Context) (*Response, error)

func (*BucketService) Get

Get Bucket请求等同于 List Object请求,可以列出该Bucket下部分或者所有Object,发起该请求需要拥有Read权限。

https://www.qcloud.com/document/product/436/7734

func (*BucketService) GetACL

GetACL 使用API读取Bucket的ACL表,只有所有者有权操作。

https://www.qcloud.com/document/product/436/7733

func (*BucketService) GetBucketReplication

func (s *BucketService) GetBucketReplication(ctx context.Context) (*GetBucketReplicationResult, *Response, error)

GetBucketReplication https://cloud.tencent.com/document/product/436/19222

func (*BucketService) GetCORS

GetCORS 实现 Bucket 跨域访问配置读取。

https://www.qcloud.com/document/product/436/8274

func (*BucketService) GetDomain

func (*BucketService) GetLifecycle

GetLifecycle 请求实现读取生命周期管理的配置。当配置不存在时,返回404 Not Found。 https://www.qcloud.com/document/product/436/8278

func (*BucketService) GetLocation

GetLocation 接口获取Bucket所在地域信息,只有Bucket所有者有权限读取信息。

https://www.qcloud.com/document/product/436/8275

func (*BucketService) GetTagging

GetTagging 接口实现获取指定Bucket的标签。

https://www.qcloud.com/document/product/436/8277

func (*BucketService) GetWebsite

func (*BucketService) Head

func (s *BucketService) Head(ctx context.Context) (*Response, error)

Head Bucket请求可以确认是否存在该Bucket,是否有权限访问,Head的权限与Read一致。

当其存在时,返回 HTTP 状态码200;
当无权限时,返回 HTTP 状态码403;
当不存在时,返回 HTTP 状态码404。

https://www.qcloud.com/document/product/436/7735

func (*BucketService) ListInventoryConfigurations

func (s *BucketService) ListInventoryConfigurations(ctx context.Context, token string) (*ListBucketInventoryConfigResult, *Response, error)

ListBucketInventoryConfigurations https://cloud.tencent.com/document/product/436/33706

func (*BucketService) ListMultipartUploads

ListMultipartUploads 用来查询正在进行中的分块上传。单次最多列出1000个正在进行中的分块上传。

https://www.qcloud.com/document/product/436/7736

func (*BucketService) Put

Put Bucket请求可以在指定账号下创建一个Bucket。

https://www.qcloud.com/document/product/436/7738

func (*BucketService) PutACL

PutACL 使用API写入Bucket的ACL表,您可以通过Header:"x-cos-acl","x-cos-grant-read", "x-cos-grant-write","x-cos-grant-full-control"传入ACL信息,也可以通过body以XML格式传入ACL信息,

但是只能选择Header和Body其中一种,否则返回冲突。

Put Bucket ACL是一个覆盖操作,传入新的ACL将覆盖原有ACL。只有所有者有权操作。

"x-cos-acl":枚举值为public-read,private;public-read意味这个Bucket有公有读私有写的权限,
private意味这个Bucket有私有读写的权限。

"x-cos-grant-read":意味被赋予权限的用户拥有该Bucket的读权限
"x-cos-grant-write":意味被赋予权限的用户拥有该Bucket的写权限
"x-cos-grant-full-control":意味被赋予权限的用户拥有该Bucket的读写权限

https://www.qcloud.com/document/product/436/7737

func (*BucketService) PutBucketReplication

func (s *BucketService) PutBucketReplication(ctx context.Context, opt *PutBucketReplicationOptions) (*Response, error)

PutBucketReplication https://cloud.tencent.com/document/product/436/19223

func (*BucketService) PutCORS

func (s *BucketService) PutCORS(ctx context.Context, opt *BucketPutCORSOptions) (*Response, error)

PutCORS 实现 Bucket 跨域访问设置,您可以通过传入XML格式的配置文件实现配置,文件大小限制为64 KB。

https://www.qcloud.com/document/product/436/8279

func (*BucketService) PutDomain

func (s *BucketService) PutDomain(ctx context.Context, opt *BucketPutDomainOptions) (*Response, error)

func (*BucketService) PutInventory

func (s *BucketService) PutInventory(ctx context.Context, id string, opt *BucketPutInventoryOptions) (*Response, error)

PutBucketInventory https://cloud.tencent.com/document/product/436/33707

func (*BucketService) PutLifecycle

func (s *BucketService) PutLifecycle(ctx context.Context, opt *BucketPutLifecycleOptions) (*Response, error)

PutLifecycle 请求实现设置生命周期管理的功能。您可以通过该请求实现数据的生命周期管理配置和定期删除。 此请求为覆盖操作,上传新的配置文件将覆盖之前的配置文件。生命周期管理对文件和文件夹同时生效。 https://www.qcloud.com/document/product/436/8280

func (*BucketService) PutLogging

func (s *BucketService) PutLogging(ctx context.Context, opt *BucketPutLoggingOptions) (*Response, error)

PutBucketLogging https://cloud.tencent.com/document/product/436/17054

func (*BucketService) PutTagging

func (s *BucketService) PutTagging(ctx context.Context, opt *BucketPutTaggingOptions) (*Response, error)

PutTagging 接口实现给用指定Bucket打标签。用来组织和管理相关Bucket。

当该请求设置相同Key名称,不同Value时,会返回400。请求成功,则返回204。

https://www.qcloud.com/document/product/436/8281

func (*BucketService) PutVersioning

func (s *BucketService) PutVersioning(ctx context.Context, opt *BucketPutVersionOptions) (*Response, error)

PutVersion https://cloud.tencent.com/document/product/436/19889 Status has Suspended\Enabled

func (*BucketService) PutWebsite

func (s *BucketService) PutWebsite(ctx context.Context, opt *BucketPutWebsiteOptions) (*Response, error)

type BucketTaggingTag

type BucketTaggingTag struct {
	Key   string
	Value string
}

BucketTaggingTag is the tag of BucketTagging

type CASJobParameters

type CASJobParameters struct {
	Tier string `xml:"Tier"`
}

CASJobParameters support three way: Standard(in 35 hours), Expedited(quick way, in 15 mins), Bulk(in 5-12 hours_

type Chunk

type Chunk struct {
	Number int
	OffSet int64
	Size   int64
}

func SplitFileIntoChunks

func SplitFileIntoChunks(filePath string, partSize int64) ([]Chunk, int, error)

type Client

type Client struct {
	Host      string
	UserAgent string
	BaseURL   *BaseURL

	Service *ServiceService
	Bucket  *BucketService
	Object  *ObjectService
	Batch   *BatchService
	// contains filtered or unexported fields
}

Client is a client manages communication with the COS API.

func NewClient

func NewClient(uri *BaseURL, httpClient *http.Client) *Client

NewClient returns a new COS API client.

type CompleteMultipartUploadOptions

type CompleteMultipartUploadOptions struct {
	XMLName       xml.Name     `xml:"CompleteMultipartUpload" header:"-" url:"-"`
	Parts         []Object     `xml:"Part" header:"-" url:"-"`
	XOptionHeader *http.Header `header:"-,omitempty" xml:"-" url:"-"`
}

CompleteMultipartUploadOptions is the option of CompleteMultipartUpload

type CompleteMultipartUploadResult

type CompleteMultipartUploadResult struct {
	XMLName  xml.Name `xml:"CompleteMultipartUploadResult"`
	Location string
	Bucket   string
	Key      string
	ETag     string
}

CompleteMultipartUploadResult is the result CompleteMultipartUpload

type CopyPartResult

type CopyPartResult struct {
	XMLName      xml.Name `xml:"CopyPartResult"`
	ETag         string
	LastModified string
}

CopyPartResult is the result CopyPart

type ErrorDocument

type ErrorDocument struct {
	Key string `xml:"Key,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	XMLName   xml.Name       `xml:"Error"`
	Response  *http.Response `xml:"-"`
	Code      string
	Message   string
	Resource  string
	RequestID string `header:"x-cos-request-id,omitempty" url:"-" xml:"-"`
	TraceID   string `xml:"TraceId,omitempty"`
}

ErrorResponse 包含 API 返回的错误信息

https://www.qcloud.com/document/product/436/7730

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error returns the error msg

type GetBucketReplicationResult

type GetBucketReplicationResult PutBucketReplicationOptions

GetBucketReplicationResult is the result of GetBucketReplication

type InitiateMultipartUploadOptions

type InitiateMultipartUploadOptions struct {
	*ACLHeaderOptions
	*ObjectPutHeaderOptions
}

InitiateMultipartUploadOptions is the option of InitateMultipartUpload

type InitiateMultipartUploadResult

type InitiateMultipartUploadResult struct {
	XMLName  xml.Name `xml:"InitiateMultipartUploadResult"`
	Bucket   string
	Key      string
	UploadID string `xml:"UploadId"`
}

InitiateMultipartUploadResult is the result of InitateMultipartUpload

type Initiator

type Initiator Owner

Initiator same to the Owner struct

type Jobs

type Jobs struct {
	Name       string
	UploadId   string
	FilePath   string
	RetryTimes int
	Chunk      Chunk
	Data       io.Reader
	Opt        *ObjectUploadPartOptions
}

jobs

type ListBucketInventoryConfigResult

type ListBucketInventoryConfigResult struct {
	XMLName                 xml.Name                           `xml:"ListInventoryConfigurationResult"`
	InventoryConfigurations []BucketListInventoryConfiguartion `xml:"InventoryConfiguration,omitempty"`
	IsTruncated             bool                               `xml:"IsTruncated,omitempty"`
	ContinuationToken       string                             `xml:"ContinuationToken,omitempty"`
	NextContinuationToken   string                             `xml:"NextContinuationToken,omitempty"`
}

ListBucketInventoryConfigResult result of ListBucketInventoryConfiguration

type ListMultipartUploadsOptions

type ListMultipartUploadsOptions struct {
	Delimiter      string `url:"delimiter,omitempty"`
	EncodingType   string `url:"encoding-type,omitempty"`
	Prefix         string `url:"prefix,omitempty"`
	MaxUploads     int    `url:"max-uploads,omitempty"`
	KeyMarker      string `url:"key-marker,omitempty"`
	UploadIDMarker string `url:"upload-id-marker,omitempty"`
}

ListMultipartUploadsOptions is the option of ListMultipartUploads

type ListMultipartUploadsResult

type ListMultipartUploadsResult struct {
	XMLName            xml.Name `xml:"ListMultipartUploadsResult"`
	Bucket             string   `xml:"Bucket"`
	EncodingType       string   `xml:"Encoding-Type"`
	KeyMarker          string
	UploadIDMarker     string `xml:"UploadIdMarker"`
	NextKeyMarker      string
	NextUploadIDMarker string `xml:"NextUploadIdMarker"`
	MaxUploads         int
	IsTruncated        bool
	Uploads            []struct {
		Key          string
		UploadID     string `xml:"UploadId"`
		StorageClass string
		Initiator    *Initiator
		Owner        *Owner
		Initiated    string
	} `xml:"Upload,omitempty"`
	Prefix         string
	Delimiter      string   `xml:"delimiter,omitempty"`
	CommonPrefixes []string `xml:"CommonPrefixs>Prefix,omitempty"`
}

ListMultipartUploadsResult is the result of ListMultipartUploads

type MultiUploadOptions

type MultiUploadOptions struct {
	OptIni         *InitiateMultipartUploadOptions
	PartSize       int64
	ThreadPoolSize int
}

MultiUploadOptions is the option of the multiupload, ThreadPoolSize default is one

type Object

type Object struct {
	Key          string `xml:",omitempty"`
	ETag         string `xml:",omitempty"`
	Size         int    `xml:",omitempty"`
	PartNumber   int    `xml:",omitempty"`
	LastModified string `xml:",omitempty"`
	StorageClass string `xml:",omitempty"`
	Owner        *Owner `xml:",omitempty"`
}

Object is the meta info of the object

type ObjectCopyHeaderOptions

type ObjectCopyHeaderOptions struct {
	// When use replace directive to update meta infos
	CacheControl                    string `header:"Cache-Control,omitempty" url:"-"`
	ContentDisposition              string `header:"Content-Disposition,omitempty" url:"-"`
	ContentEncoding                 string `header:"Content-Encoding,omitempty" url:"-"`
	ContentLanguage                 string `header:"Content-Language,omitempty" url:"-"`
	ContentType                     string `header:"Content-Type,omitempty" url:"-"`
	Expires                         string `header:"Expires,omitempty" url:"-"`
	Expect                          string `header:"Expect,omitempty" url:"-"`
	XCosMetadataDirective           string `header:"x-cos-metadata-directive,omitempty" url:"-" xml:"-"`
	XCosCopySourceIfModifiedSince   string `header:"x-cos-copy-source-If-Modified-Since,omitempty" url:"-" xml:"-"`
	XCosCopySourceIfUnmodifiedSince string `header:"x-cos-copy-source-If-Unmodified-Since,omitempty" url:"-" xml:"-"`
	XCosCopySourceIfMatch           string `header:"x-cos-copy-source-If-Match,omitempty" url:"-" xml:"-"`
	XCosCopySourceIfNoneMatch       string `header:"x-cos-copy-source-If-None-Match,omitempty" url:"-" xml:"-"`
	XCosStorageClass                string `header:"x-cos-storage-class,omitempty" url:"-" xml:"-"`
	// 自定义的 x-cos-meta-* header
	XCosMetaXXX              *http.Header `header:"x-cos-meta-*,omitempty" url:"-"`
	XCosCopySource           string       `header:"x-cos-copy-source" url:"-" xml:"-"`
	XCosServerSideEncryption string       `header:"x-cos-server-side-encryption,omitempty" url:"-" xml:"-"`
	// SSE-C
	XCosSSECustomerAglo             string `header:"x-cos-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKey              string `header:"x-cos-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKeyMD5           string `header:"x-cos-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"`
	XCosCopySourceSSECustomerAglo   string `header:"x-cos-copy-source-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"`
	XCosCopySourceSSECustomerKey    string `header:"x-cos-copy-source-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"`
	XCosCopySourceSSECustomerKeyMD5 string `header:"x-cos-copy-source-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"`
	//兼容其他自定义头部
	XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"`
}

ObjectCopyHeaderOptions is the head option of the Copy

type ObjectCopyOptions

type ObjectCopyOptions struct {
	*ObjectCopyHeaderOptions `header:",omitempty" url:"-" xml:"-"`
	*ACLHeaderOptions        `header:",omitempty" url:"-" xml:"-"`
}

ObjectCopyOptions is the option of Copy, choose header or body

type ObjectCopyPartOptions

type ObjectCopyPartOptions struct {
	XCosCopySource                  string `header:"x-cos-copy-source" url:"-"`
	XCosCopySourceRange             string `header:"x-cos-copy-source-range,omitempty" url:"-"`
	XCosCopySourceIfModifiedSince   string `header:"x-cos-copy-source-If-Modified-Since,omitempty" url:"-"`
	XCosCopySourceIfUnmodifiedSince string `header:"x-cos-copy-source-If-Unmodified-Since,omitempty" url:"-"`
	XCosCopySourceIfMatch           string `header:"x-cos-copy-source-If-Match,omitempty" url:"-"`
	XCosCopySourceIfNoneMatch       string `header:"x-cos-copy-source-If-None-Match,omitempty" url:"-"`
}

ObjectCopyPartOptions is the options of copy-part

type ObjectCopyResult

type ObjectCopyResult struct {
	XMLName      xml.Name `xml:"CopyObjectResult"`
	ETag         string   `xml:"ETag,omitempty"`
	LastModified string   `xml:"LastModified,omitempty"`
}

ObjectCopyResult is the result of Copy

type ObjectDeleteMultiOptions

type ObjectDeleteMultiOptions struct {
	XMLName xml.Name `xml:"Delete" header:"-"`
	Quiet   bool     `xml:"Quiet" header:"-"`
	Objects []Object `xml:"Object" header:"-"`
}

ObjectDeleteMultiOptions is the option of DeleteMulti

type ObjectDeleteMultiResult

type ObjectDeleteMultiResult struct {
	XMLName        xml.Name `xml:"DeleteResult"`
	DeletedObjects []Object `xml:"Deleted,omitempty"`
	Errors         []struct {
		Key     string
		Code    string
		Message string
	} `xml:"Error,omitempty"`
}

ObjectDeleteMultiResult is the result of DeleteMulti

type ObjectGetACLResult

type ObjectGetACLResult ACLXml

ObjectGetACLResult is the result of GetObjectACL

type ObjectGetOptions

type ObjectGetOptions struct {
	ResponseContentType        string `url:"response-content-type,omitempty" header:"-"`
	ResponseContentLanguage    string `url:"response-content-language,omitempty" header:"-"`
	ResponseExpires            string `url:"response-expires,omitempty" header:"-"`
	ResponseCacheControl       string `url:"response-cache-control,omitempty" header:"-"`
	ResponseContentDisposition string `url:"response-content-disposition,omitempty" header:"-"`
	ResponseContentEncoding    string `url:"response-content-encoding,omitempty" header:"-"`
	Range                      string `url:"-" header:"Range,omitempty"`
	IfModifiedSince            string `url:"-" header:"If-Modified-Since,omitempty"`
	// SSE-C
	XCosSSECustomerAglo   string `header:"x-cos-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKey    string `header:"x-cos-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKeyMD5 string `header:"x-cos-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"`
}

ObjectGetOptions is the option of GetObject

type ObjectHeadOptions

type ObjectHeadOptions struct {
	IfModifiedSince string `url:"-" header:"If-Modified-Since,omitempty"`
	// SSE-C
	XCosSSECustomerAglo   string `header:"x-cos-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKey    string `header:"x-cos-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKeyMD5 string `header:"x-cos-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"`
}

ObjectHeadOptions is the option of HeadObject

type ObjectList

type ObjectList []Object

ObjectList can used for sort the parts which needs in complete upload part sort.Sort(cos.ObjectList(opt.Parts))

func (ObjectList) Len

func (o ObjectList) Len() int

func (ObjectList) Less

func (o ObjectList) Less(i, j int) bool

func (ObjectList) Swap

func (o ObjectList) Swap(i, j int)

type ObjectListPartsOptions

type ObjectListPartsOptions struct {
	EncodingType     string `url:"Encoding-type,omitempty"`
	MaxParts         string `url:"max-parts,omitempty"`
	PartNumberMarker string `url:"part-number-marker,omitempty"`
}

ObjectListPartsOptions is the option of ListParts

type ObjectListPartsResult

type ObjectListPartsResult struct {
	XMLName              xml.Name `xml:"ListPartsResult"`
	Bucket               string
	EncodingType         string `xml:"Encoding-type,omitempty"`
	Key                  string
	UploadID             string     `xml:"UploadId"`
	Initiator            *Initiator `xml:"Initiator,omitempty"`
	Owner                *Owner     `xml:"Owner,omitempty"`
	StorageClass         string
	PartNumberMarker     string
	NextPartNumberMarker string `xml:"NextPartNumberMarker,omitempty"`
	MaxParts             string
	IsTruncated          bool
	Parts                []Object `xml:"Part,omitempty"`
}

ObjectListPartsResult is the result of ListParts

type ObjectOptionsOptions

type ObjectOptionsOptions struct {
	Origin                      string `url:"-" header:"Origin"`
	AccessControlRequestMethod  string `url:"-" header:"Access-Control-Request-Method"`
	AccessControlRequestHeaders string `url:"-" header:"Access-Control-Request-Headers,omitempty"`
}

ObjectOptionsOptions is the option of object options

type ObjectPutACLOptions

type ObjectPutACLOptions struct {
	Header *ACLHeaderOptions `url:"-" xml:"-"`
	Body   *ACLXml           `url:"-" header:"-"`
}

ObjectPutACLOptions the options of put object acl

type ObjectPutHeaderOptions

type ObjectPutHeaderOptions struct {
	CacheControl       string `header:"Cache-Control,omitempty" url:"-"`
	ContentDisposition string `header:"Content-Disposition,omitempty" url:"-"`
	ContentEncoding    string `header:"Content-Encoding,omitempty" url:"-"`
	ContentType        string `header:"Content-Type,omitempty" url:"-"`
	ContentMD5         string `header:"Content-MD5,omitempty" url:"-"`
	ContentLength      int    `header:"Content-Length,omitempty" url:"-"`
	ContentLanguage    string `header:"Content-Language,omitempty" url:"-"`
	Expect             string `header:"Expect,omitempty" url:"-"`
	Expires            string `header:"Expires,omitempty" url:"-"`
	XCosContentSHA1    string `header:"x-cos-content-sha1,omitempty" url:"-"`
	// 自定义的 x-cos-meta-* header
	XCosMetaXXX      *http.Header `header:"x-cos-meta-*,omitempty" url:"-"`
	XCosStorageClass string       `header:"x-cos-storage-class,omitempty" url:"-"`
	// 可选值: Normal, Appendable
	//XCosObjectType string `header:"x-cos-object-type,omitempty" url:"-"`
	// Enable Server Side Encryption, Only supported: AES256
	XCosServerSideEncryption string `header:"x-cos-server-side-encryption,omitempty" url:"-" xml:"-"`
	// SSE-C
	XCosSSECustomerAglo   string `header:"x-cos-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKey    string `header:"x-cos-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKeyMD5 string `header:"x-cos-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"`
	//兼容其他自定义头部
	XOptionHeader *http.Header `header:"-,omitempty" url:"-" xml:"-"`
}

ObjectPutHeaderOptions the options of header of the put object

type ObjectPutOptions

type ObjectPutOptions struct {
	*ACLHeaderOptions       `header:",omitempty" url:"-" xml:"-"`
	*ObjectPutHeaderOptions `header:",omitempty" url:"-" xml:"-"`
}

ObjectPutOptions the options of put object

type ObjectRestoreOptions

type ObjectRestoreOptions struct {
	XMLName xml.Name          `xml:"RestoreRequest"`
	Days    int               `xml:"Days"`
	Tier    *CASJobParameters `xml:"CASJobParameters"`
}

ObjectRestoreOptions is the option of object restore

type ObjectService

type ObjectService service

ObjectService 相关 API

func (*ObjectService) AbortMultipartUpload

func (s *ObjectService) AbortMultipartUpload(ctx context.Context, name, uploadID string) (*Response, error)

AbortMultipartUpload 用来实现舍弃一个分块上传并删除已上传的块。当您调用Abort Multipart Upload时, 如果有正在使用这个Upload Parts上传块的请求,则Upload Parts会返回失败。当该UploadID不存在时,会返回404 NoSuchUpload。

建议您及时完成分块上传或者舍弃分块上传,因为已上传但是未终止的块会占用存储空间进而产生存储费用。

https://www.qcloud.com/document/product/436/7740

func (*ObjectService) CompleteMultipartUpload

func (s *ObjectService) CompleteMultipartUpload(ctx context.Context, name, uploadID string, opt *CompleteMultipartUploadOptions) (*CompleteMultipartUploadResult, *Response, error)

CompleteMultipartUpload 用来实现完成整个分块上传。当您已经使用Upload Parts上传所有块以后,你可以用该API完成上传。 在使用该API时,您必须在Body中给出每一个块的PartNumber和ETag,用来校验块的准确性。

由于分块上传的合并需要数分钟时间,因而当合并分块开始的时候,COS就立即返回200的状态码,在合并的过程中, COS会周期性的返回空格信息来保持连接活跃,直到合并完成,COS会在Body中返回合并后块的内容。

当上传块小于1 MB的时候,在调用该请求时,会返回400 EntityTooSmall; 当上传块编号不连续的时候,在调用该请求时,会返回400 InvalidPart; 当请求Body中的块信息没有按序号从小到大排列的时候,在调用该请求时,会返回400 InvalidPartOrder; 当UploadId不存在的时候,在调用该请求时,会返回404 NoSuchUpload。

建议您及时完成分块上传或者舍弃分块上传,因为已上传但是未终止的块会占用存储空间进而产生存储费用。

https://www.qcloud.com/document/product/436/7742

func (*ObjectService) Copy

func (s *ObjectService) Copy(ctx context.Context, name, sourceURL string, opt *ObjectCopyOptions, id ...string) (*ObjectCopyResult, *Response, error)

Copy 调用 PutObjectCopy 请求实现将一个文件从源路径复制到目标路径。建议文件大小 1M 到 5G, 超过 5G 的文件请使用分块上传 Upload - Copy。在拷贝的过程中,文件元属性和 ACL 可以被修改。

用户可以通过该接口实现文件移动,文件重命名,修改文件属性和创建副本。

注意:在跨帐号复制的时候,需要先设置被复制文件的权限为公有读,或者对目标帐号赋权,同帐号则不需要。

https://cloud.tencent.com/document/product/436/10881

func (*ObjectService) CopyPart

func (s *ObjectService) CopyPart(ctx context.Context, name, uploadID string, partNumber int, sourceURL string, opt *ObjectCopyPartOptions) (*CopyPartResult, *Response, error)

CopyPart 请求实现在初始化以后的分块上传,支持的块的数量为1到10000,块的大小为1 MB 到5 GB。 在每次请求Upload Part时候,需要携带partNumber和uploadID,partNumber为块的编号,支持乱序上传。 ObjectCopyPartOptions的XCosCopySource为必填参数,格式为<bucket-name>-<app-id>.cos.<region-id>.myqcloud.com/<object-key> ObjectCopyPartOptions的XCosCopySourceRange指定源的Range,格式为bytes=<start>-<end>

当传入uploadID和partNumber都相同的时候,后传入的块将覆盖之前传入的块。当uploadID不存在时会返回404错误,NoSuchUpload.

https://www.qcloud.com/document/product/436/7750

func (*ObjectService) Delete

func (s *ObjectService) Delete(ctx context.Context, name string) (*Response, error)

Delete Object请求可以将一个文件(Object)删除。

https://www.qcloud.com/document/product/436/7743

func (*ObjectService) DeleteMulti

DeleteMulti 请求实现批量删除文件,最大支持单次删除1000个文件。 对于返回结果,COS提供Verbose和Quiet两种结果模式。Verbose模式将返回每个Object的删除结果; Quiet模式只返回报错的Object信息。 https://www.qcloud.com/document/product/436/8289

func (*ObjectService) Get

func (s *ObjectService) Get(ctx context.Context, name string, opt *ObjectGetOptions, id ...string) (*Response, error)

Get Object 请求可以将一个文件(Object)下载至本地。 该操作需要对目标 Object 具有读权限或目标 Object 对所有人都开放了读权限(公有读)。

https://www.qcloud.com/document/product/436/7753

func (*ObjectService) GetACL

GetACL Get Object ACL接口实现使用API读取Object的ACL表,只有所有者有权操作。

https://www.qcloud.com/document/product/436/7744

func (*ObjectService) GetPresignedURL

func (s *ObjectService) GetPresignedURL(ctx context.Context, httpMethod, name, ak, sk string, expired time.Duration, opt interface{}) (*url.URL, error)

GetPresignedURL get the object presigned to down or upload file by url

func (*ObjectService) GetToFile

func (s *ObjectService) GetToFile(ctx context.Context, name, localpath string, opt *ObjectGetOptions, id ...string) (*Response, error)

GetToFile download the object to local file

func (*ObjectService) Head

func (s *ObjectService) Head(ctx context.Context, name string, opt *ObjectHeadOptions, id ...string) (*Response, error)

Head Object请求可以取回对应Object的元数据,Head的权限与Get的权限一致

https://www.qcloud.com/document/product/436/7745

func (*ObjectService) InitiateMultipartUpload

InitiateMultipartUpload 请求实现初始化分片上传,成功执行此请求以后会返回Upload ID用于后续的Upload Part请求。

https://www.qcloud.com/document/product/436/7746

func (*ObjectService) ListParts

func (s *ObjectService) ListParts(ctx context.Context, name, uploadID string, opt *ObjectListPartsOptions) (*ObjectListPartsResult, *Response, error)

ListParts 用来查询特定分块上传中的已上传的块。

https://www.qcloud.com/document/product/436/7747

func (*ObjectService) MultiUpload

MultiUpload/Upload 为高级upload接口,并发分块上传 注意该接口目前只供参考

当 partSize > 0 时,由调用者指定分块大小,否则由 SDK 自动切分,单位为MB 由调用者指定分块大小时,请确认分块数量不超过10000

func (*ObjectService) Options

func (s *ObjectService) Options(ctx context.Context, name string, opt *ObjectOptionsOptions) (*Response, error)

Options Object请求实现跨域访问的预请求。即发出一个 OPTIONS 请求给服务器以确认是否可以进行跨域操作。

当CORS配置不存在时,请求返回403 Forbidden。

https://www.qcloud.com/document/product/436/8288

func (*ObjectService) PostRestore

func (s *ObjectService) PostRestore(ctx context.Context, name string, opt *ObjectRestoreOptions) (*Response, error)

PutRestore API can recover an object of type archived by COS archive.

https://cloud.tencent.com/document/product/436/12633

func (*ObjectService) Put

func (s *ObjectService) Put(ctx context.Context, name string, r io.Reader, opt *ObjectPutOptions) (*Response, error)

Put Object请求可以将一个文件(Oject)上传至指定Bucket。

当 r 不是 bytes.Buffer/bytes.Reader/strings.Reader 时,必须指定 opt.ObjectPutHeaderOptions.ContentLength

https://www.qcloud.com/document/product/436/7749

func (*ObjectService) PutACL

func (s *ObjectService) PutACL(ctx context.Context, name string, opt *ObjectPutACLOptions) (*Response, error)

PutACL 使用API写入Object的ACL表,您可以通过Header:"x-cos-acl", "x-cos-grant-read" , "x-cos-grant-write" ,"x-cos-grant-full-control"传入ACL信息, 也可以通过body以XML格式传入ACL信息,但是只能选择Header和Body其中一种,否则,返回冲突。

Put Object ACL是一个覆盖操作,传入新的ACL将覆盖原有ACL。只有所有者有权操作。

"x-cos-acl":枚举值为public-read,private;public-read意味这个Object有公有读私有写的权限, private意味这个Object有私有读写的权限。

"x-cos-grant-read":意味被赋予权限的用户拥有该Object的读权限

"x-cos-grant-write":意味被赋予权限的用户拥有该Object的写权限

"x-cos-grant-full-control":意味被赋予权限的用户拥有该Object的读写权限

https://www.qcloud.com/document/product/436/7748

func (*ObjectService) PutFromFile

func (s *ObjectService) PutFromFile(ctx context.Context, name string, filePath string, opt *ObjectPutOptions) (*Response, error)

PutFromFile put object from local file Notice that when use this put large file need set non-body of debug req/resp, otherwise will out of memory

func (*ObjectService) Upload

func (*ObjectService) UploadPart

func (s *ObjectService) UploadPart(ctx context.Context, name, uploadID string, partNumber int, r io.Reader, opt *ObjectUploadPartOptions) (*Response, error)

UploadPart 请求实现在初始化以后的分块上传,支持的块的数量为1到10000,块的大小为1 MB 到5 GB。 在每次请求Upload Part时候,需要携带partNumber和uploadID,partNumber为块的编号,支持乱序上传。

当传入uploadID和partNumber都相同的时候,后传入的块将覆盖之前传入的块。当uploadID不存在时会返回404错误,NoSuchUpload.

当 r 不是 bytes.Buffer/bytes.Reader/strings.Reader 时,必须指定 opt.ContentLength

https://www.qcloud.com/document/product/436/7750

type ObjectUploadPartOptions

type ObjectUploadPartOptions struct {
	Expect          string `header:"Expect,omitempty" url:"-"`
	XCosContentSHA1 string `header:"x-cos-content-sha1" url:"-"`
	ContentLength   int    `header:"Content-Length,omitempty" url:"-"`

	XCosSSECustomerAglo   string `header:"x-cos-server-side-encryption-customer-algorithm,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKey    string `header:"x-cos-server-side-encryption-customer-key,omitempty" url:"-" xml:"-"`
	XCosSSECustomerKeyMD5 string `header:"x-cos-server-side-encryption-customer-key-MD5,omitempty" url:"-" xml:"-"`
}

ObjectUploadPartOptions is the options of upload-part

type Owner

type Owner struct {
	UIN         string `xml:"uin,omitempty"`
	ID          string `xml:",omitempty"`
	DisplayName string `xml:",omitempty"`
}

Owner defines Bucket/Object's owner

type PutBucketReplicationOptions

type PutBucketReplicationOptions struct {
	XMLName xml.Name                `xml:"ReplicationConfiguration"`
	Role    string                  `xml:"Role"`
	Rule    []BucketReplicationRule `xml:"Rule"`
}

PutBucketReplicationOptions is the options of PutBucketReplication

type RedirectRequestsProtocol

type RedirectRequestsProtocol struct {
	Protocol string `xml:"Protocol,omitempty"`
}

type ReplicationDestination

type ReplicationDestination struct {
	Bucket       string `xml:"Bucket"`
	StorageClass string `xml:"StorageClass,omitempty"`
}

ReplicationDestination is the sub struct of BucketReplicationRule

type Response

type Response struct {
	*http.Response
}

Response API 响应

type Results

type Results struct {
	PartNumber int
	Resp       *Response
}

type ServiceGetResult

type ServiceGetResult struct {
	XMLName xml.Name `xml:"ListAllMyBucketsResult"`
	Owner   *Owner   `xml:"Owner"`
	Buckets []Bucket `xml:"Buckets>Bucket,omitempty"`
}

ServiceGetResult is the result of Get Service

type ServiceService

type ServiceService service

Service 相关 API

func (*ServiceService) Get

Get Service 接口实现获取该用户下所有Bucket列表。

该API接口需要使用Authorization签名认证, 且只能获取签名中AccessID所属账户的Bucket列表。

https://www.qcloud.com/document/product/436/8291

type WebsiteRoutingRule

type WebsiteRoutingRule struct {
	ConditionErrorCode string `xml:"Condition>HttpErrorCodeReturnedEquals,omitempty"`
	ConditionPrefix    string `xml:"Condition>KeyPrefixEquals,omitempty"`

	RedirectProtocol         string `xml:"Redirect>Protocol,omitempty"`
	RedirectReplaceKey       string `xml:"Redirect>ReplaceKeyWith,omitempty"`
	RedirectReplaceKeyPrefix string `xml:"Redirect>ReplaceKeyPrefixWith,omitempty"`
}

type WebsiteRoutingRules

type WebsiteRoutingRules struct {
	Rules []WebsiteRoutingRule `xml:"RoutingRule,omitempty"`
}

Directories

Path Synopsis
example
sts

Jump to

Keyboard shortcuts

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