pcs

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

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

Go to latest
Published: May 11, 2014 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET    = "GET"
	POST   = "POST"
	PUT    = "PUT"
	HEAD   = "HEAD"
	DELETE = "DELETE"
)
View Source
const (
	ERROR_CUSTOM      = 8000 //一般用户操作错误
	ERROR_CUSTOM_JSON = 8001 //json解析错误
	ERROR_OTHER       = 8002 //其他错误
)
View Source
const (
	FileList_OrderBy_MTime = "time" //修改时间
	FileList_OrderBy_Name  = "name" //文件名
	FileList_OrderBy_Size  = "size" //大小,注意目录无大小

	FileList_Order_Asc  = "asc"  //升序
	FileList_Order_Desc = "desc" //降序 缺省采用降序排序
)
View Source
const (
	PCS_HOST = "https://c.pcs.baidu.com/rest/2.0/pcs/"
)

Variables

This section is empty.

Functions

func PrintRequestInfo

func PrintRequestInfo(req *http.Request)

func PrintResponseInfo

func PrintResponseInfo(res *http.Response, err error)

Types

type FileDownloadInfo

type FileDownloadInfo struct {
	ContentLength int64
	Content_MD5   string
	Content_Type  string
	Mtime         int64
}

type Pcs

type Pcs struct {
	Debug bool
	// contains filtered or unexported fields
}

func NewPcs

func NewPcs(accessToken string) *Pcs

func (*Pcs) BuildRequest

func (pcs *Pcs) BuildRequest(method string, params string, body io.Reader) *http.Request

func (*Pcs) DoRequest

func (pcs *Pcs) DoRequest(req *http.Request) (resp *http.Response, err error)

func (*Pcs) FileCopy

func (pcs *Pcs) FileCopy(from string, to string) (info *ResponseFileCopy, pcs_err *PcsError)

func (*Pcs) FileDelete

func (pcs *Pcs) FileDelete(path string) (info *ResponseOk, pcs_err *PcsError)

func (*Pcs) FileDeleteBatch

func (pcs *Pcs) FileDeleteBatch(paths []string) (info *ResponseOk, pcs_err *PcsError)

批量删除接口

func (*Pcs) FileDownload

func (pcs *Pcs) FileDownload(path string, writer io.Writer) (info *FileDownloadInfo, pcs_err *PcsError)

文件下载

func (*Pcs) FileList

func (pcs *Pcs) FileList(path string, orderby string, order string, offset int, limit int) (info *ResponseFileList, pcs_err *PcsError)

* *@param path string *@param orderby string 排序字段 *@param order string 排序方式 *@param offset int 结果集偏移量 从0开始 *@param limit int 结果集条数

func (*Pcs) FileListEasy

func (pcs *Pcs) FileListEasy(path string) (*ResponseFileList, *PcsError)

func (*Pcs) FileMakeDir

func (pcs *Pcs) FileMakeDir(path string) (info *ResponseFileMakeDir, pcs_err *PcsError)

func (*Pcs) FileMeta

func (pcs *Pcs) FileMeta(path string) (*ResponseFileMeta, *PcsError)

批量获取文件或目录的元信息

func (*Pcs) FileMetaBatch

func (pcs *Pcs) FileMetaBatch(paths []string) (meta *ResponseFileMeta, pcs_err *PcsError)

func (*Pcs) FileMove

func (pcs *Pcs) FileMove(from string, to string) (info *ResponseFileCopy, pcs_err *PcsError)

func (*Pcs) FileSearch

func (pcs *Pcs) FileSearch(path string, query string, recursive bool) (info *ResponseFileMeta, pcs_err *PcsError)

* *@param path string *@param query string 关键词 *@param recursive string 是否递归

func (*Pcs) FileUploadSingle

func (pcs *Pcs) FileUploadSingle(data io.Reader, server_path string, ondup_overwrite bool) (resSingle *ResponseFileUpload, pcs_err *PcsError)

func (*Pcs) FileUploadSlice

func (pcs *Pcs) FileUploadSlice(data io.Reader) (resSlice *ResponseFileUploadSlice, pcs_err *PcsError)

分片上传,2G以内

func (*Pcs) FileUploadSliceMerge

func (pcs *Pcs) FileUploadSliceMerge(block_list []string, server_path string, ondup_overwrite bool) (resInfo *ResponseFileUpload, pcs_err *PcsError)

分片上传—合并分片文件

func (*Pcs) GetQuota

func (pcs *Pcs) GetQuota() (*ResponseQuote, error)

func (*Pcs) QuickRequest

func (pcs *Pcs) QuickRequest(req *http.Request, v interface{}) (resp *http.Response, resp_body []byte, pcs_err *PcsError)

type PcsError

type PcsError struct {
	Error_code int                    `json:"error_code"`
	Error_msg  string                 `json:"error_msg"`
	Request_id int                    `json:"request_id"`
	Extra      map[string]interface{} `json:"extra"`
}

func NewPcsError

func NewPcsError(err_code int, msg string) *PcsError

func (*PcsError) Error

func (e *PcsError) Error() string

type Quote

type Quote struct {
	QuotaSize int64 `json:"quota"`
	UsedSize  int64 `json:"used"`
	RequestId int64 `json:"request_id"`
}

func (*Quote) String

func (quote *Quote) String() string

type ResponseFileCopy

type ResponseFileCopy struct {
	Extra      ResponseFileCopyList `json:"extra"`
	Request_id uint64               `json:"request_id"`
}

func (*ResponseFileCopy) String

func (rt *ResponseFileCopy) String() string

type ResponseFileCopyDetail

type ResponseFileCopyDetail struct {
	From string `json:"from"`
	To   string `json:"to"`
}

type ResponseFileCopyList

type ResponseFileCopyList struct {
	List []ResponseFileCopyDetail `json:"list"`
}

type ResponseFileList

type ResponseFileList struct {
	List       []ResponseFileListDetail `json:"list"`
	Request_id uint64                   `json:"request_id"`
}

func (*ResponseFileList) String

func (rt *ResponseFileList) String() string

type ResponseFileListDetail

type ResponseFileListDetail struct {
	Fs_id uint64 `json:"fs_id"`
	Path  string `json:"path"`
	Ctime int64  `json:"ctime"`
	Mtime int64  `json:"mtime"`
	Md5   string `json:"md5"`
	Size  uint64 `json:"size"`  //文件大小(byte)。
	IsDir uint64 `json:"isdir"` //0为文件  1为目录
}

type ResponseFileMakeDir

type ResponseFileMakeDir struct {
	Fs_id uint64 `json:"fs_id"` //文件或目录在PCS的临时唯一标识ID。
	Path  string `json:"path"`
	Ctime int64  `json:"ctime"`
	Mtime int64  `json:"mtime"`
}

func (*ResponseFileMakeDir) String

func (rt *ResponseFileMakeDir) String() string

type ResponseFileMeta

type ResponseFileMeta struct {
	List       []ResponseFileMeta_SubInfo `json:"list"`
	Request_id uint64                     `json:"request_id"` //是否含有子目录的标识符 “0”表示没有子目录  “1”表示有子目录
}

单个文件或目录的元信息

func (*ResponseFileMeta) String

func (rt *ResponseFileMeta) String() string

type ResponseFileMeta_SubInfo

type ResponseFileMeta_SubInfo struct {
	Fs_id       uint64 `json:"fs_id"` //文件或目录在PCS的临时唯一标识ID。
	Path        string `json:"path"`
	Ctime       int64  `json:"ctime"`
	Mtime       int64  `json:"mtime"`
	Block_list  string `json:"block_list"` //文件所有分片的md5数组JSON字符串。
	Size        uint64 `json:"size"`
	Isdir       int    `json:"isdir"` //“0”为文件 “1”为目录
	Filenum     int    `json:"filenum"`
	Ifhassubdir int    `json:"ifhassubdir"` //是否含有子目录的标识符 “0”表示没有子目录  “1”表示有子目录
}

type ResponseFileUpload

type ResponseFileUpload struct {
	Path  string `json:"path"`
	Size  uint64 `json:"size"`
	Ctime int64  `json:"ctime"`
	Mtime int64  `json:"mtime"`
	Md5   string `json:"md5"`
	Fs_id string `json:"fs_id "`
}

* *单个文件上传的

func (*ResponseFileUpload) String

func (rt *ResponseFileUpload) String() string

type ResponseFileUploadSlice

type ResponseFileUploadSlice struct {
	Md5   string `json:"md5"`
	Fs_id string `json:"fs_id "`
}

* *文件分片

type ResponseOk

type ResponseOk struct {
	RequestId uint64 `json:"request_id"`
}

func (*ResponseOk) String

func (rt *ResponseOk) String() string

type ResponseQuote

type ResponseQuote struct {
	QuotaSize int64  `json:"quota"`
	UsedSize  uint64 `json:"used"`
	RequestId uint64 `json:"request_id"`
}

func (*ResponseQuote) String

func (rt *ResponseQuote) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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