Documentation ¶
Index ¶
- func CheckAuthorizationConfig(config AuthorizationConfig) error
- func ConfirmAuthorization(client *cos.Client) error
- func DownloadToLocal(client *BucketClient, objectKey, localPath, filename string) error
- func HeadBucket(client *cos.Client) error
- type ACLHeaderOptions
- type AuthorizationClient
- type AuthorizationConfig
- type Bucket
- type BucketCORSRule
- type BucketClient
- func (c *BucketClient) Copy(sourceKey, destKey string, force bool, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
- func (c *BucketClient) Delete() error
- func (c *BucketClient) DeleteObject(objectKey string) error
- func (c *BucketClient) DownloadObject(objectKey string, writer io.Writer) error
- func (c *BucketClient) GetCORS() ([]BucketCORSRule, error)
- func (c *BucketClient) GetObject(objectKey string, opt *ObjectGetOptions) (*http.Response, error)
- func (c *BucketClient) HeadObject(objectKey string, opt *ObjectHeadOptions) (*http.Response, error)
- func (c *BucketClient) ListObjects(opt *BucketGetOptions) ([]Object, error)
- func (c *BucketClient) Move(sourceKey, destKey string, force bool, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
- func (c *BucketClient) ObjectDownloadURL(objectKey string) (string, error)
- func (c *BucketClient) ObjectStaticURL(objectKey string) (string, error)
- func (c *BucketClient) PutCORS(opt *BucketPutCORSOptions) error
- func (c *BucketClient) PutObject(objectKey string, reader io.Reader, force bool, opt *ObjectPutOptions) (*http.Response, error)
- func (c *BucketClient) Rename(sourceKey, fileName string, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
- type BucketConfig
- type BucketGetOptions
- type BucketPutCORSOptions
- type BucketPutOptions
- type Object
- type ObjectCopyHeaderOptions
- type ObjectCopyOptions
- type ObjectCopyResult
- type ObjectGetOptions
- type ObjectHeadOptions
- type ObjectPutHeaderOptions
- type ObjectPutOptions
- type OpError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAuthorizationConfig ¶
func CheckAuthorizationConfig(config AuthorizationConfig) error
CheckAuthorizationConfig ...
func ConfirmAuthorization ¶
func ConfirmAuthorization(client *cos.Client) error
ConfirmAuthorization is used to confirm authorization info
func DownloadToLocal ¶
func DownloadToLocal(client *BucketClient, objectKey, localPath, filename string) error
DownloadToLocal object to local
func HeadBucket ¶
func HeadBucket(client *cos.Client) error
HeadBucket tests bucket is available or not Status: 200 - ok, 403 - Forbidden, 404 - Not Found
Types ¶
type ACLHeaderOptions ¶
type ACLHeaderOptions = cos.ACLHeaderOptions
ACLHeaderOptions see Permission-related headers in https://intl.cloud.tencent.com/document/product/436/7749#non-common-header
type AuthorizationClient ¶
type AuthorizationClient struct { *AuthorizationConfig Client *cos.Client }
AuthorizationClient is used for services.
func CreateAuthorizationClient ¶
func CreateAuthorizationClient(config AuthorizationConfig) (*AuthorizationClient, error)
CreateAuthorizationClient creates a service client. Client contains BaseURL, common service, *ServiceService, *BucketService, *ObjectService
func (*AuthorizationClient) CreateBucketClient ¶
func (c *AuthorizationClient) CreateBucketClient(bucket *Bucket) (*BucketClient, error)
CreateBucketClient is used to get a bucket client by AuthorizationClient
func (*AuthorizationClient) ListBuckets ¶
func (c *AuthorizationClient) ListBuckets() ([]Bucket, error)
ListBuckets is used to get all buckets of authorized user
func (*AuthorizationClient) Service ¶
func (c *AuthorizationClient) Service() (*cos.ServiceGetResult, error)
Service returns a service, which contains Owner and Buckets.
type AuthorizationConfig ¶
type AuthorizationConfig struct { AppID string // mandatory SecretID string // mandatory SecretKey string // mandatory }
AuthorizationConfig contains AppID, SecretID, SecretKey. AppID can be used to create a new bucket. SecretID & SecretKey are used for AuthorizationTransport. Get values from https://console.cloud.tencent.com/cam/capi Set policy for permission in https://console.cloud.tencent.com/cam/policy
type Bucket ¶
type Bucket = cos.Bucket
Bucket contains Name, AppID, Region, CreateDate of created bucket
type BucketCORSRule ¶
type BucketCORSRule = cos.BucketCORSRule
BucketCORSRule : 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"`
type BucketClient ¶
type BucketClient struct { *BucketConfig Client *cos.Client }
BucketClient is used for bucket operation
func CreateBucketClient ¶
func CreateBucketClient(config BucketConfig) (*BucketClient, error)
CreateBucketClient creates a bucket client, which can request bucket operations
func PutBucket ¶
func PutBucket(config BucketConfig, options *BucketPutOptions) (*BucketClient, error)
PutBucket is used to create a new bucket. options: https://intl.cloud.tencent.com/document/product/436/7738#request-header
func (*BucketClient) Copy ¶
func (c *BucketClient) Copy(sourceKey, destKey string, force bool, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
Copy sourceKey to destKey. Enable force will overwrite file if destKey exists. This action can be used to copy, move, rename and reset object
func (*BucketClient) Delete ¶
func (c *BucketClient) Delete() error
Delete the bucket. The bucket must be empty before deleting.
func (*BucketClient) DeleteObject ¶
func (c *BucketClient) DeleteObject(objectKey string) error
DeleteObject is used to delete one file (Object) in Bucket. This action requires WRITE permission for the Bucket. if the named object doesn't exist, delete operation is ok and return 204 - No Content
func (*BucketClient) DownloadObject ¶
func (c *BucketClient) DownloadObject(objectKey string, writer io.Writer) error
DownloadObject ...
func (*BucketClient) GetCORS ¶
func (c *BucketClient) GetCORS() ([]BucketCORSRule, error)
GetCORS output CORS of basic-config in bucket
func (*BucketClient) GetObject ¶
func (c *BucketClient) GetObject(objectKey string, opt *ObjectGetOptions) (*http.Response, error)
GetObject ...
func (*BucketClient) HeadObject ¶
func (c *BucketClient) HeadObject(objectKey string, opt *ObjectHeadOptions) (*http.Response, error)
HeadObject requests object meta info. if opt specified "IfModifiedSince" Header and object is not modified, response 304
func (*BucketClient) ListObjects ¶
func (c *BucketClient) ListObjects(opt *BucketGetOptions) ([]Object, error)
ListObjects is used to get all objects in bucket. This action requires READ permission for the Bucket. see options details in https://intl.cloud.tencent.com/document/product/436/7734#request-parameters
func (*BucketClient) Move ¶
func (c *BucketClient) Move(sourceKey, destKey string, force bool, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
Move object
func (*BucketClient) ObjectDownloadURL ¶
func (c *BucketClient) ObjectDownloadURL(objectKey string) (string, error)
ObjectDownloadURL ...
func (*BucketClient) ObjectStaticURL ¶
func (c *BucketClient) ObjectStaticURL(objectKey string) (string, error)
ObjectStaticURL return static url, which can be embedded in website NOTICE: This action need enable static website in basicconfig of bucket
func (*BucketClient) PutCORS ¶
func (c *BucketClient) PutCORS(opt *BucketPutCORSOptions) error
PutCORS config
func (*BucketClient) PutObject ¶
func (c *BucketClient) PutObject(objectKey string, reader io.Reader, force bool, opt *ObjectPutOptions) (*http.Response, error)
PutObject to bucket. This action requires WRITE permission for the Bucket. enable force will overwrite object if ObjectAlreadyExists
func (*BucketClient) Rename ¶
func (c *BucketClient) Rename(sourceKey, fileName string, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
Rename object TODO: Rename directory
type BucketConfig ¶
type BucketConfig struct { *AuthorizationConfig // mandatory Name string // mandatory Region string // mandatory, see: https://intl.cloud.tencent.com/document/product/436/6224 }
BucketConfig contains AuthorizationConfig, Name, Region. AuthorizationConfig is needed, for more information see service.go When creating new bucket, Name & Region is mandatory.
type BucketGetOptions ¶
type BucketGetOptions = cos.BucketGetOptions
BucketGetOptions contains request parameters of ListObjects() see options details in https://intl.cloud.tencent.com/document/product/436/7734#request-parameters
type BucketPutCORSOptions ¶
type BucketPutCORSOptions = cos.BucketPutCORSOptions
BucketPutCORSOptions contains XMLName and BucketCORSRule details see https://intl.cloud.tencent.com/document/product/436/8279#request-body
type BucketPutOptions ¶
type BucketPutOptions = cos.BucketPutOptions
BucketPutOptions in https://intl.cloud.tencent.com/document/product/436/7738#request-header
type Object ¶
type Object = cos.Object
Object contains Key, ETag, Size, PartNumber, LastModified, StorageClass, Owner of created object e.g. Object{Key:"text.txt", ETag:"\"847f4281d3e9ad10844ef37da835cfc0\"", Size:4545, PartNumber:0, LastModified:"2018-05-22T14:39:23.000Z", StorageClass:"STANDARD", Owner:(*cos.Owner)(0xc42018bb00)}
type ObjectCopyHeaderOptions ¶
type ObjectCopyHeaderOptions = cos.ObjectCopyHeaderOptions
ObjectCopyHeaderOptions see https://cloud.tencent.com/document/product/436/10881#.E9.9D.9E.E5.85.AC.E5.85.B1.E5.A4.B4.E9.83.A8
type ObjectCopyOptions ¶
type ObjectCopyOptions = cos.ObjectCopyOptions
ObjectCopyOptions contains ObjectCopyHeaderOptions and ACLHeaderOptions
type ObjectCopyResult ¶
type ObjectCopyResult = cos.ObjectCopyResult
ObjectCopyResult ...
func Copy ¶
func Copy(client *BucketClient, sourceKey, destKey string, force bool, opt *ObjectCopyOptions) (*ObjectCopyResult, *http.Response, error)
Copy ...
type ObjectGetOptions ¶
type ObjectGetOptions = cos.ObjectGetOptions
ObjectGetOptions is used for GetObject() details see https://intl.cloud.tencent.com/document/product/436/7753
type ObjectHeadOptions ¶
type ObjectHeadOptions = cos.ObjectHeadOptions
ObjectHeadOptions specified "IfModifiedSince" Header
type ObjectPutHeaderOptions ¶
type ObjectPutHeaderOptions = cos.ObjectPutHeaderOptions
ObjectPutHeaderOptions see Recommended Header in https://intl.cloud.tencent.com/document/product/436/7749#non-common-header
type ObjectPutOptions ¶
type ObjectPutOptions = cos.ObjectPutOptions
ObjectPutOptions contains ACLHeaderOptions and ObjectPutHeaderOptions details see https://intl.cloud.tencent.com/document/product/436/7749#request-header