cos

package module
v0.0.0-...-e40e716 Latest Latest
Warning

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

Go to latest
Published: May 15, 2017 License: GPL-3.0 Imports: 17 Imported by: 0

README

DEPRECATED

Tencent Qcloud COS updated its RESTful API. This library does not support the new API. I am no longer maintaining this library.

cos-go

Tencent Qcloud Cloud Object Service RESTful JSON API Go library.

腾讯云 对象存储服务(COS) RESTful JSON API Go 语言库。

License

Copyright (C) 2016-2017 Laurence Liu liuxy6@gmail.com

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Documentation

Index

Constants

View Source
const (
	COSEndPoint     = "http://web.file.myqcloud.com/files/v1/%v/%v/%v" // appid, bucket name, path
	COSFileEndPoint = "http://%v-%v.file.myqcloud.com/%v"              // bucket name, appid, path
	ExpiredSeconds  = 600
	ListBoth        = "eListBoth"
	ListFileOnly    = "eListFileOnly"
	ListDirOnly     = "eListDirOnly"
)

Variables

View Source
var Logger = log.New(os.Stdout, "", log.LstdFlags)

Functions

func FormatResponse

func FormatResponse(response *Response) (ret string)

func GetURLSafePath

func GetURLSafePath(path string) (safePath string, err error)

func NormPath

func NormPath(path string) string

Types

type Config

type Config struct {
	Appid     string
	SecretID  string
	SecretKey string
}

type Cos

type Cos struct {
	Config
	ExpiredSeconds int64
	InsertOnly     int
	Client         http.Client
}

func New

func New(appid, secretID, secretKey string) (cos *Cos)

func (*Cos) CreateFolder

func (cos *Cos) CreateFolder(bucket, path string) (ret *Response, err error)

func (*Cos) Delete

func (cos *Cos) Delete(bucket, path string) (ret []*Response, err error)

func (*Cos) DeleteFile

func (cos *Cos) DeleteFile(bucket, path string) (*Response, error)

func (*Cos) DeleteFolder

func (cos *Cos) DeleteFolder(bucket, path string) (*Response, error)

func (*Cos) DownloadFile

func (cos *Cos) DownloadFile(bucket, path, localPath string) (err error)

func (*Cos) DownloadFolder

func (cos *Cos) DownloadFolder(bucket, path, localPath string) (err error)

func (*Cos) GetAccessURL

func (cos *Cos) GetAccessURL(bucket, path string) string

func (*Cos) GetAccessURLWithToken

func (cos *Cos) GetAccessURLWithToken(bucket, path string, expireTime int64) string

func (*Cos) GetResURL

func (cos *Cos) GetResURL(bucket, path string) string

func (*Cos) GetSHA

func (cos *Cos) GetSHA(bucket, path string) (ret string, err error)

func (*Cos) IsBucketPublic

func (cos *Cos) IsBucketPublic(bucket string) (ret bool, err error)

func (*Cos) List

func (cos *Cos) List(bucket, path string, num uint64, pattern string, order int8, context string) (ret *Response, err error)

func (*Cos) Scan

func (cos *Cos) Scan(bucket, path string, depth int) (ret []map[string]interface{}, err error)

Scan scan specified folder or file depth > 0:

scan specified levels

depth < 0:

scan recursively

func (*Cos) SignMore

func (cos *Cos) SignMore(bucket string, expired int64) string

func (*Cos) SignOnce

func (cos *Cos) SignOnce(bucket, fileID string) string

func (*Cos) StatFile

func (cos *Cos) StatFile(bucket, path string) (*Response, error)

func (*Cos) StatFolder

func (cos *Cos) StatFolder(bucket, path string) (*Response, error)

func (*Cos) Upload

func (cos *Cos) Upload(file io.Reader, bucket, path string) (ret *Response, err error)

func (*Cos) UploadFile

func (cos *Cos) UploadFile(filePath, bucket, path string) (ret *Response, err error)

func (*Cos) UploadFolder

func (cos *Cos) UploadFolder(folderPath, bucket, path string) (ret []*Response, err error)

func (*Cos) UploadSlice

func (cos *Cos) UploadSlice(file io.ReadSeeker, bucket, path string) (ret *Response, err error)

type Response

type Response struct {
	HTTPCode int
	Code     int64                  `json:"code"`
	Message  string                 `json:"message"`
	Data     map[string]interface{} `json:"data"`
}

func ProcessResponse

func ProcessResponse(httpResponse *http.Response) (cosResponse *Response, err error)

Jump to

Keyboard shortcuts

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