cli

package
v0.0.0-...-c24aeb1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package cli implements functions used to call the API in Tencent Cloud COS(Cloud Object Storage). These functions are all in a struct Client.

If you want to use the functions in this package, you should first fill the field of struct ClientConfig, and call NewClient to generate one Client, and use this client to call the functions you need.

Index

Constants

View Source
const (
	Expedited = iota
	Standard
	Bulk
)
View Source
const (
	VERSION = "1.8.6.22"
)

Variables

View Source
var (
	Region         string
	ConfigPath     string
	LogPath        string
	Bucket         string
	DebugMode      bool
	LogBackupCount int
	LogSize        int
)

Functions

This section is empty.

Types

type AbortFile

type AbortFile struct {
	Key      string
	UploadID string
}

type Client

type Client struct {
	Client *cos.Client
	Config *ClientConfig
}

func NewClient

func NewClient(config *ClientConfig) *Client

Create a new client.

func (*Client) AbortParts

func (client *Client) AbortParts(cosPath string) bool

func (*Client) CopyFile

func (client *Client) CopyFile(sourcePath string, cosPath string, headers *http.Header, options *CopyOption) int

sourcePath: bucket-appid.cos.ap-guangzhou.myqcloud.com/path/to/file cosPath: test/file

func (*Client) CopyFolder

func (client *Client) CopyFolder(sourcePath string, cosPath string, headers *http.Header, options *CopyOption) int

sourcePath: bucket-appid.cos.ap-guangzhou.myqcloud.com/path/ cosPath: test/

func (*Client) CreateBucket

func (client *Client) CreateBucket() bool

func (*Client) DeleteBucket

func (client *Client) DeleteBucket(force bool) bool

func (*Client) DeleteFile

func (client *Client) DeleteFile(cosPath string, options *DeleteOption) int

func (*Client) DeleteFolder

func (client *Client) DeleteFolder(cosPath string, options *DeleteOption) int

func (*Client) DeleteObjects

func (client *Client) DeleteObjects(deleteList []string) (successNum int, failNum int)

func (*Client) DownloadFile

func (client *Client) DownloadFile(cosPath string, localPath string, _ *http.Header, options *DownloadOption) int

func (*Client) DownloadFolder

func (client *Client) DownloadFolder(cosPath string, localPath string, options *DownloadOption) int

func (*Client) GetBucketACL

func (client *Client) GetBucketACL() bool

GetBucketACL will get the ACL configured in client and prints it. if all things goes smoothly while requesting the information, return true. Otherwise, return false.

func (*Client) GetBucketVersioning

func (client *Client) GetBucketVersioning() bool

func (*Client) GetObjectACL

func (client *Client) GetObjectACL(cosPath string) bool

func (*Client) InfoObject

func (client *Client) InfoObject(cosPath string, _ bool) bool

func (*Client) ListMultipartObjects

func (client *Client) ListMultipartObjects(cosPath string) bool

func (*Client) ListObjects

func (client *Client) ListObjects(cosPath string, options *ListOption) bool

func (*Client) PutBucketACL

func (client *Client) PutBucketACL(grantRead, grantWrite, grantFullControl, cosPath string) bool

PutBucketACL reads the grant strings and applied them to bucketPath specified. If everything goes ok, return true. Otherwise(like network connection failed, no such remote object), return false.

func (*Client) PutBucketVersioning

func (client *Client) PutBucketVersioning(versioning bool) bool

func (*Client) PutObjectACL

func (client *Client) PutObjectACL(grantRead, grantWrite, grantFullControl, cosPath string) bool

PutObjectACL reads the grant strings and applied them to cosPath specified. If everything goes ok, return true. Otherwise(like network connection failed, no such remote object), return false.

func (*Client) RestoreFile

func (client *Client) RestoreFile(cosPath string, options *RestoreOption) int

func (*Client) RestoreFolder

func (client *Client) RestoreFolder(cosPath string, options *RestoreOption) int

func (*Client) UploadFile

func (client *Client) UploadFile(localPath string, cosPath string, headers *http.Header, options *UploadOption) int

Upload a single file.

func (*Client) UploadFolder

func (client *Client) UploadFolder(localPath string, cosPath string, headers *http.Header, options *UploadOption) int

Upload a folder.

type ClientConfig

type ClientConfig struct {
	SecretID     string
	SecretKey    string
	Token        string
	Bucket       string
	Endpoint     string
	MaxThread    int
	PartSize     int
	RetryTimes   int
	Timeout      int
	Schema       string
	VerifyMethod string
	Anonymous    bool
}

func LoadConf

func LoadConf(configPath string) *ClientConfig

Load config from config file path and return a ClientConfig.

type CopyOption

type CopyOption struct {
	Sync      bool
	Force     bool
	Yes       bool
	Directive string
	SkipMd5   bool
	Ignore    []string
	Include   []string
	Delete    bool
	Move      bool
}

type DeleteOption

type DeleteOption struct {
	Force     bool
	Yes       bool
	Versions  bool
	VersionID string
}

type DownloadOption

type DownloadOption struct {
	Force   bool
	Yes     bool
	Sync    bool
	Num     int
	Ignore  []string
	Include []string
	SkipMd5 bool
	Delete  bool
}

type FileDesc

type FileDesc struct {
	Path      string
	Type      string
	Size      int64
	Time      string
	Class     string
	VersionID string
}

type ListOption

type ListOption struct {
	Recursive bool
	All       bool
	Num       int
	Human     bool
	Versions  bool
}

type PathPair

type PathPair struct {
	LocalPath string
	CosPath   string
}

type RestoreOption

type RestoreOption struct {
	Day  int
	Tier int
}

type UploadOption

type UploadOption struct {
	SkipMd5 bool
	Sync    bool
	Include []string
	Ignore  []string
	Force   bool
	Yes     bool
	Delete  bool
}

Jump to

Keyboard shortcuts

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