Documentation
¶
Overview ¶
Index ¶
- Constants
- Variables
- func GetClient() *sdk.APIClient
- func GetLogger() *logrus.Logger
- func IsLoggerDebug() bool
- func LogInfoString(w io.Writer, s string)
- func SetLogLevel(level logrus.Level)
- func SetOutputFile(path string) error
- func SetOutputWriter(w io.Writer) error
- func ToInterface[T any](r *http.Response, args ...any) (*T, error)
- type ApiErr
- type Async
- type BatchGetFileInfoReq
- type BatchGetFileInfoRes
- type CreateFileReq
- type CreateFileRes
- type ErrorRes
- type FileInfo
- func (f FileInfo) GetCategory() string
- func (f FileInfo) GetFileType() string
- func (f FileInfo) GetFileTypeEmoji() string
- func (f FileInfo) GetFileTypeIcon() string
- func (f FileInfo) GetFilename() string
- func (f FileInfo) GetLocalCTime() string
- func (f FileInfo) GetLocalMTime() string
- func (f FileInfo) GetServerCTime() string
- func (f FileInfo) GetServerMTime() string
- func (f FileInfo) GetSize() string
- func (f FileInfo) IsDir() bool
- type FileManager
- type FileManagerInfo
- type GetDeviceCodeRes
- type GetDeviceTokenRes
- type GetFileInfoReq
- type GetFileInfoRes
- type GetFileListAllReq
- type GetFileListAllRes
- type GetFileListReq
- type GetFileListRes
- type GetPanInfoRes
- type GetUserInfoRes
- type Icon
- type LogFormatter
- type ManageFileReq
- type ManageFileRes
- func DeleteFiles(accessToken string, paths ...string) (*ManageFileRes, error)
- func ManageFile(accessToken string, req *ManageFileReq) (*ManageFileRes, error)
- func MoveFiles(accessToken string, dir string, paths ...string) (*ManageFileRes, error)
- func RenameFiles(accessToken string, files ...*FileManager) (*ManageFileRes, error)
- type Ondup
- type Opera
- type PreCreateFileReq
- func (r *PreCreateFileReq) GetBlockListString() string
- func (r *PreCreateFileReq) SetContentMD5(contentMD5 string) *PreCreateFileReq
- func (r *PreCreateFileReq) SetLocalCTime(localCTime string) *PreCreateFileReq
- func (r *PreCreateFileReq) SetLocalMTime(localMTime string) *PreCreateFileReq
- func (r *PreCreateFileReq) SetRtype(rtype int32) *PreCreateFileReq
- func (r *PreCreateFileReq) SetSliceMD5(sliceMD5 string) *PreCreateFileReq
- func (r *PreCreateFileReq) SetUploadid(uploadid string) *PreCreateFileReq
- type PreCreateFileRes
- type SearchFileReq
- type SearchFileRes
- type UploadFilePartReq
- type UploadFilePartRes
Constants ¶
const ( OndupFail Ondup = "fail" OndupNewCopy = "newcopy" OndupOverwrite = "overwrite" OndupSkip = "skip" AsyncSync Async = iota AsyncSelfAdaptation AsyncAsync OperaMove Opera = "move" OperaCopy = "copy" OperaDelete = "delete" OperaRename = "rename" )
Variables ¶
var ( // 公共错误码 Success = ApiErr{ Errno: 0, ErrMsg: "请求成功", Remark: "成功", } ErrUnknown = ApiErr{ Errno: 1, ErrMsg: "未知错误", Remark: "服务器内部错误,请再次请求,如果持续出现此类错误,请提交工单反馈", } ApiErrParamError = ApiErr{ Errno: 2, ErrMsg: "参数错误", Remark: "检查必选参数是否都已填写;检查参数位置,有的参数是在url里,有的是在body里;检查每个参数的值是否正确", } ErrUnsupportedMethod = ApiErr{ Errno: 3, ErrMsg: "未知的方法", Remark: "调用的API不存在,请检查后重新尝试", } ErrRequestLimitReached = ApiErr{ Errno: 4, ErrMsg: "接口请求过于频繁", Remark: "接口调用次数已达到设定的上限,请控制请求频率", } Errno: 5, ErrMsg: "请求来自未经授权的IP地址", Remark: "请求IP不在白名单内", } ErrNoPermission = ApiErr{ Errno: 6, ErrMsg: "无权限访问该用户数据", Remark: "应用无权限访问该用户数据,请为应用配置权限", } ErrInvalidParameter = ApiErr{ Errno: 100, ErrMsg: "请求参数无效", Remark: "检查请求参数是否正确", } ErrInvalidApiKey = ApiErr{ Errno: 101, ErrMsg: "API Key无效", Remark: "检查API Key是否正确", } ErrInvalidAccessToken = ApiErr{ Errno: 110, ErrMsg: "无效的access token", Remark: "access token无效或已过期", } ErrAccessTokenExpired = ApiErr{ Errno: 111, ErrMsg: "access token过期", Remark: "access token已过期,请重新获取", } // 百度网盘特有错误码 ErrOperationFailed = ApiErr{ Errno: -1, ErrMsg: "操作失败", Remark: "检查网络连接是否正常,尝试重新登录或重启百度网盘客户端", } ErrFileNotFound = ApiErr{ Errno: -3, ErrMsg: "文件不存在", Remark: "文件不存在", } ErrAuthFailed = ApiErr{ Errno: -6, ErrMsg: "身份验证失败", Remark: "access_token 是否有效; 授权是否成功;参考接入授权FAQ;阅读文档《使用入门->接入授权》章节", } ErrPathError = ApiErr{ Errno: -7, ErrMsg: "文件或目录名错误或无权访问", Remark: "文件或目录名有误", } ApiErrPathExists = ApiErr{ Errno: -8, ErrMsg: "文件或目录已存在", Remark: "文件或目录已存在", } ApiErrPathNotFound = ApiErr{ Errno: -9, ErrMsg: "文件或目录不存在", Remark: "文件或目录不存在", } ErrSaveFileExists = ApiErr{ Errno: 10, ErrMsg: "转存文件已经存在", Remark: "转存文件已经存在", } ErrUserNotExists = ApiErr{ Errno: 11, ErrMsg: "用户不存在", Remark: "uid不存在", } ErrBatchSaveFailed = ApiErr{ Errno: 12, ErrMsg: "批量转存出错", Remark: "参数错误,检查转存源和目的是不是同一个uid,正常不应该是一个 uid", } ErrAsyncTaskRunning = ApiErr{ Errno: 111, ErrMsg: "有其他异步任务正在执行", Remark: "稍后,可重新请求", } ErrAppReviewing = ApiErr{ Errno: 20011, ErrMsg: "应用审核中", Remark: "仅限前10个完成OAuth授权的用户测试应用", } ErrAccessLimited = ApiErr{ Errno: 20012, ErrMsg: "访问超限", Remark: "调用次数已达上限,触发限流", } ErrPermissionDenied = ApiErr{ Errno: 20013, ErrMsg: "权限不足", Remark: "当前应用无接口权限", } ErrInvalidParam = ApiErr{ Errno: 31023, ErrMsg: "参数错误", Remark: "检查必选参数是否都已填写;检查参数位置,有的参数是在url里,有的是在body里;检查每个参数的值是否正确", } ErrNoAccessPermission = ApiErr{ Errno: 31024, ErrMsg: "没有访问权限", Remark: "检查授权应用方式", } ErrApiFreqLimit9013 = ApiErr{ Errno: 9013, ErrMsg: "命中接口频控", Remark: "接口请求过于频繁,注意控制", } ErrApiFreqLimit9019 = ApiErr{ Errno: 9019, ErrMsg: "命中接口频控", Remark: "接口请求过于频繁,注意控制", } ErrApiFreqLimit = ApiErr{ Errno: 31034, ErrMsg: "命中接口频控", Remark: "接口请求过于频繁,注意控制", } ErrAccessTokenInvalid = ApiErr{ Errno: 31045, ErrMsg: "access_token验证未通过", Remark: "请检查access_token是否过期,用户授权时是否勾选网盘权限等", } ErrFileAlreadyExists = ApiErr{ Errno: 31061, ErrMsg: "文件已存在", Remark: "文件已存在", } ErrInvalidFilename = ApiErr{ Errno: 31062, ErrMsg: "文件名无效", Remark: "检查是否包含特殊字符", } ErrUploadPathError = ApiErr{ Errno: 31064, ErrMsg: "上传路径错误", Remark: "上传文件的绝对路径格式:/apps/申请接入时填写的产品名称", } ErrFilenameNotFound = ApiErr{ Errno: 31066, ErrMsg: "文件名不存在", Remark: "排查文件是否存储,路径是否传错", } ErrFileMissing = ApiErr{ Errno: 31190, ErrMsg: "文件不存在", Remark: "block_list参数是否正确;一般是分片上传阶段有问题;检查分片上传阶段,分片传完了么;size大小对不对,跟实际文件是否一致,跟预上传接口的size是否一致", } ErrFirstChunkTooSmall = ApiErr{ Errno: 31299, ErrMsg: "第一个分片的大小小于4MB", Remark: "要等于4MB", } ErrNotMediaFile = ApiErr{ Errno: 31301, ErrMsg: "非音视频文件", Remark: "文件类型是否是音视频", } ErrInvalidVideoFormat = ApiErr{ Errno: 31304, ErrMsg: "视频格式不支持播放", Remark: "视频格式不支持播放", } ErrAntiHotlink = ApiErr{ Errno: 31326, ErrMsg: "命中防盗链", Remark: "查看自己请求是否合理,User-Agent请求头是否正常", } ErrVideoBitrateTooHigh = ApiErr{ Errno: 31338, ErrMsg: "当前视频码率太高暂不支持流畅播放", Remark: "用户下载后播放", } ErrIllegalMediaFile = ApiErr{ Errno: 31339, ErrMsg: "非法媒体文件", Remark: "检查视频内容", } ErrVideoTranscoding = ApiErr{ Errno: 31341, ErrMsg: "视频正在转码", Remark: "可重新请求", } ErrVideoTranscodeFailed = ApiErr{ Errno: 31346, ErrMsg: "视频转码失败", Remark: "排查该文件是否是个正常的视频", } ErrVideoTooLong = ApiErr{ Errno: 31347, ErrMsg: "当前视频太长,暂不支持在线播放", Remark: "建议用户下载后播放", } ErrParamAbnormal = ApiErr{ Errno: 31355, ErrMsg: "参数异常", Remark: "一般是 uploadid 参数传的有问题,确认uploadid参数传的是否与预上传precreate接口下发的uploadid一致", } ErrUrlExpired = ApiErr{ Errno: 31360, ErrMsg: "url过期", Remark: "请重新获取", } ErrSignError = ApiErr{ Errno: 31362, ErrMsg: "签名错误", Remark: "请检查链接地址是否完整", } ErrMissingChunks = ApiErr{ Errno: 31363, ErrMsg: "分片缺失", Remark: "分片是否全部上传;每个上传的分片是否正确;size大小是否正确,跟实际文件是否一致,跟预上传接口的size是否一致", } ErrChunkSizeExceeded = ApiErr{ Errno: 31364, ErrMsg: "超出分片大小限制", Remark: "建议以4MB作为上限", } ErrFileSizeExceeded = ApiErr{ Errno: 31365, ErrMsg: "文件总大小超限", Remark: "授权用户为普通用户时,单个分片大小固定为4MB,单文件总大小上限为4GB;授权用户为普通会员时,单个分片大小", } )
https://pan.baidu.com/union/doc/okumlx17r
var Version = "0.1.9"
Functions ¶
func IsLoggerDebug ¶
func IsLoggerDebug() bool
func LogInfoString ¶
func SetLogLevel ¶
Types ¶
type ApiErr ¶ added in v0.1.0
type ApiErr struct {
Errno int32 `json:"errno,omitempty"`
ErrMsg string `json:"errmsg"`
Remark string
}
https://pan.baidu.com/union/doc/okumlx17r
func GetApiErrByErrno ¶ added in v0.1.0
根据Errno获取对应的ApiErr实例
type BatchGetFileInfoReq ¶
func NewBatchGetFileListReq ¶
func NewBatchGetFileListReq(fsid uint64) *BatchGetFileInfoReq
func (*BatchGetFileInfoReq) AppendFSID ¶
func (r *BatchGetFileInfoReq) AppendFSID(fsid ...uint64) *BatchGetFileInfoReq
func (*BatchGetFileInfoReq) GetDlink ¶
func (r *BatchGetFileInfoReq) GetDlink() string
func (*BatchGetFileInfoReq) GetFSIDString ¶
func (r *BatchGetFileInfoReq) GetFSIDString() string
type BatchGetFileInfoRes ¶
type BatchGetFileInfoRes struct {
List []*FileInfo `json:"list"`
}
func BatchGetFileInfo ¶
func BatchGetFileInfo(accessToken string, req *BatchGetFileInfoReq) (*BatchGetFileInfoRes, error)
批量获取文件详情
type CreateFileReq ¶ added in v0.1.0
type CreateFileReq struct {
// 上传后使用的文件绝对路径,需要urlencode,需要与预上传precreate接口中的path保持一致
Path string
// 文件或目录的大小,必须要和文件真实大小保持一致,需要与预上传precreate接口中的size保持一致
Size int32
// 是否目录,0 文件、1 目录,需要与预上传precreate接口中的isdir保持一致
Isdir int32
// 预上传precreate接口下发的uploadid
Uploadid string
// 文件各分片md5数组的json串需要与预上传precreate接口中的block_list保持一致,同时对应分片上传superfile2接口返回的md5,且要按照序号顺序排列
BlockList []string
// 文件命名策略,默认0
// 0 为不重命名,返回冲突
// 1 为只要path冲突即重命名
// 2 为path冲突且block_list不同才重命名
// 3 为覆盖,需要与预上传precreate接口中的rtype保持一致
Rtype int32
// 客户端创建时间(精确到秒),默认为当前时间戳
LocalCTime int64
// 客户端修改时间(精确到秒),默认为当前时间戳
LocalMTime int64
}
CreateFileReq 创建文件请求参数 https://pan.baidu.com/union/doc/rksg0sa17 将多个文件分片合并成一个文件,生成文件基本信息,完成文件的上传最后一步。
func NewCreateFileReq ¶ added in v0.1.0
func NewCreateFileReq(path string, size int32, isdir int32, uploadid string, blockList []string) *CreateFileReq
CreateFileReq 创建文件请求参数
func (*CreateFileReq) GetBlockListString ¶ added in v0.1.0
func (r *CreateFileReq) GetBlockListString() string
GetBlockListString 返回block_list的json字符串
func (*CreateFileReq) SetLocalCTime ¶ added in v0.1.0
func (r *CreateFileReq) SetLocalCTime(localCTime int64) *CreateFileReq
func (*CreateFileReq) SetLocalMTime ¶ added in v0.1.0
func (r *CreateFileReq) SetLocalMTime(localMTime int64) *CreateFileReq
func (*CreateFileReq) SetRtype ¶ added in v0.1.0
func (r *CreateFileReq) SetRtype(rtype int32) *CreateFileReq
type CreateFileRes ¶ added in v0.1.0
type CreateFileRes struct {
ErrorRes
// 文件在云端的唯一标识ID
FSID uint64 `json:"fs_id,omitempty"`
// 文件的MD5,只有提交文件时才返回,提交目录时没有该值
Md5 string `json:"md5,omitempty"`
// 文件名
ServerFilename string `json:"server_filename,omitempty"`
// 分类类型, 1 视频 2 音频 3 图片 4 文档 5 应用 6 其他 7 种子
Category int32 `json:"category,omitempty"`
// 上传后使用的文件绝对路径
Path string `json:"path,omitempty"`
// 文件大小,单位B
Size uint64 `json:"size,omitempty"`
// 文件创建时间
Ctime uint64 `json:"ctime,omitempty"`
// 文件修改时间
Mtime uint64 `json:"mtime,omitempty"`
// 是否目录,0 文件、1 目录
Isdir int32 `json:"isdir,omitempty"`
// 请求ID
RequestId int64 `json:"request_id,omitempty"`
}
CreateFileRes 创建文件响应参数
func CreateFile ¶ added in v0.1.0
func CreateFile(accessToken string, req *CreateFileReq) (*CreateFileRes, error)
创建文件 https://pan.baidu.com/union/doc/rksg0sa17 将多个文件分片合并成一个文件,生成文件基本信息,完成文件的上传最后一步。
type ErrorRes ¶ added in v0.1.0
type FileInfo ¶
type FileInfo struct {
FSID uint64 `json:"fs_id"`
Path string `json:"path"`
Size int `json:"size"`
FileType int `json:"isdir"`
Filename string `json:"filename"`
ServerFilename string `json:"server_filename"`
Category int `json:"category"`
Dlink string `json:"dlink"`
MD5 string `json:"md5"`
Thumbs map[string]string `json:"thumbs"`
ServerCTime int64 `json:"server_ctime"`
ServerMTime int64 `json:"server_mtime"`
LocalCTime int64 `json:"local_ctime"`
LocalMTime int64 `json:"local_mtime"`
}
func (FileInfo) GetCategory ¶
func (FileInfo) GetFileType ¶
func (FileInfo) GetFileTypeEmoji ¶
func (FileInfo) GetFileTypeIcon ¶
func (FileInfo) GetFilename ¶
func (FileInfo) GetLocalCTime ¶
func (FileInfo) GetLocalMTime ¶
func (FileInfo) GetServerCTime ¶
func (FileInfo) GetServerMTime ¶
type FileManager ¶
type FileManager struct {
Path string `json:"path,omitempty"`
Newname string `json:"newname,omitempty"`
Dest string `json:"dest,omitempty"`
Ondup string `json:"ondup,omitempty"`
}
func NewFileManager ¶
func NewFileManager(path, dest, newname string) *FileManager
type FileManagerInfo ¶
type GetDeviceCodeRes ¶ added in v0.1.9
type GetDeviceCodeRes struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURL string `json:"verification_url"`
QrcodeURL string `json:"qrcode_url"`
ExpiresIn int64 `json:"expires_in"`
Interval int64 `json:"interval"`
}
func GetDeviceCode ¶ added in v0.1.9
func GetDeviceCode(appKey, scope string) (*GetDeviceCodeRes, error)
获取登录使用 code 二维码 scope: 一般使用 basic,netdisk
type GetDeviceTokenRes ¶ added in v0.1.9
type GetDeviceTokenRes struct {
ExpiresIn int32 `json:"expires_in,omitempty"`
RefreshToken string `json:"refresh_token,omitempty"`
AccessToken string `json:"access_token,omitempty"`
SessionSecret string `json:"session_secret,omitempty"`
SessionKey string `json:"session_key,omitempty"`
Scope string `json:"scope,omitempty"`
}
func GetDeviceToken ¶ added in v0.1.9
func GetDeviceToken(appKey, secretKey, code string) (*GetDeviceTokenRes, error)
通过 code 获取用户身份 token
type GetFileInfoReq ¶
func NewGetFileInfoReq ¶
func NewGetFileInfoReq(fsid uint64) *GetFileInfoReq
type GetFileInfoRes ¶
type GetFileInfoRes struct {
FileInfo
}
func GetFileInfo ¶
func GetFileInfo(accessToken string, req *GetFileInfoReq) (*GetFileInfoRes, error)
type GetFileListAllReq ¶ added in v0.1.3
type GetFileListAllReq struct {
Path string
Recursion int
Web int
Start uint64
Limit uint32
Order string
Desc int
}
func NewGetFileListAllReq ¶ added in v0.1.3
func NewGetFileListAllReq(path string) *GetFileListAllReq
type GetFileListAllRes ¶ added in v0.1.3
type GetFileListAllRes struct {
List []*FileInfo `json:"list"`
RequestID string `json:"request_id"`
HasMore int `json:"has_more"`
Cursor uint64 `json:"cursor"`
ErrorRes
}
func GetFileListAll ¶ added in v0.1.3
func GetFileListAll(accessToken string, req *GetFileListAllReq) (*GetFileListAllRes, error)
GetFileListAll 递归获取文件列表 https://pan.baidu.com/union/doc/Zksg0sb73
type GetFileListReq ¶
type GetFileListReq struct {
Dir string
Web int
Start int
Limit int32
// 排序字段:默认为name;
// time表示先按文件类型排序,后按修改时间排序;
// name表示先按文件类型排序,后按文件名称排序;
// size表示先按文件类型排序,后按文件大小排序。
Order string
// 默认为升序,设置为1实现降序 (注:排序的对象是当前目录下所有文件,不是当前分页下的文件)
Desc int32
// contains filtered or unexported fields
}
func NewGetFileListReq ¶
func NewGetFileListReq() *GetFileListReq
func (*GetFileListReq) SetDir ¶
func (r *GetFileListReq) SetDir(dir string) *GetFileListReq
func (*GetFileListReq) SetLimit ¶
func (r *GetFileListReq) SetLimit(limit int32) *GetFileListReq
func (*GetFileListReq) SetPage ¶
func (r *GetFileListReq) SetPage(page int) *GetFileListReq
type GetFileListRes ¶
type GetFileListRes struct {
GuidInfo string `json:"guid_info"`
Errmsg string `json:"errmsg"`
List []*FileInfo `json:"list"`
}
func GetFileList ¶
func GetFileList(accessToken string, req *GetFileListReq) (*GetFileListRes, error)
type GetPanInfoRes ¶
type GetPanInfoRes struct {
*openapi.Quotaresponse
}
func GetPanInfo ¶
func GetPanInfo(accessToken string) (*GetPanInfoRes, error)
func (GetPanInfoRes) GetTotalStr ¶
func (p GetPanInfoRes) GetTotalStr() string
func (GetPanInfoRes) GetUsedStr ¶
func (p GetPanInfoRes) GetUsedStr() string
type GetUserInfoRes ¶
type GetUserInfoRes struct {
*openapi.Uinforesponse
}
func GetUserInfo ¶
func GetUserInfo(accessToken string) (*GetUserInfoRes, error)
func (GetUserInfoRes) GetVipName ¶
func (u GetUserInfoRes) GetVipName() string
type Icon ¶
type Icon struct {
Name string `json:"name"`
Icon string `json:"icon"`
Color string `json:"color"`
}
func GetDefaultFileIcon ¶
func GetDefaultFileIcon() Icon
func GetIconByExt ¶
func GetIconByPath ¶
type LogFormatter ¶
type LogFormatter struct {
*logrus.TextFormatter
}
type ManageFileReq ¶
type ManageFileReq struct {
Filelist []*FileManager
// 0 同步,1 自适应,2 异步
Async Async
// 全局ondup,遇到重复文件的处理策略,
// fail(默认,直接返回失败)、newcopy(重命名文件)、overwrite、skip
Ondup Ondup
// 文件操作参数,可实现文件复制、移动、重命名、删除,依次对应的参数值为:copy、move、rename、delete
Opera Opera
}
https://pan.baidu.com/union/doc/mksg0s9l4?from=open-sdk-go
func NewManageFileReq ¶
func NewManageFileReq( opera Opera, filelist []*FileManager, ) *ManageFileReq
func (ManageFileReq) GetFilelistString ¶
func (r ManageFileReq) GetFilelistString() string
type ManageFileRes ¶
type ManageFileRes struct {
ErrorRes
Infos []FileManagerInfo `json:"info,omitempty"`
RequestId int64 `json:"request_id,omitempty"`
Taskid int64 `json:"taskid,omitempty"`
}
func DeleteFiles ¶
func DeleteFiles(accessToken string, paths ...string) (*ManageFileRes, error)
删除文件列表
func ManageFile ¶
func ManageFile(accessToken string, req *ManageFileReq) (*ManageFileRes, error)
func MoveFiles ¶
func MoveFiles(accessToken string, dir string, paths ...string) (*ManageFileRes, error)
移动文件列表
func RenameFiles ¶ added in v0.1.4
func RenameFiles(accessToken string, files ...*FileManager) (*ManageFileRes, error)
重命名 RenameFiles(token, NewFileManager("/apps/bdpan/test.go", "", "new.go"))
type PreCreateFileReq ¶ added in v0.1.0
type PreCreateFileReq struct {
// 上传后使用的文件绝对路径,需要urlencode
Path string
// 文件和目录两种情况:上传文件时,表示文件的大小,单位B;上传目录时,表示目录的大小,目录的话大小默认为0
Size int32
// 是否为目录,0 文件,1 目录
Isdir int32
// 固定值1
Autoinit int32
// 文件各分片MD5数组的json串
// 如果上传的文件小于4MB,其md5值(32位小写)即为block_list字符串数组的唯一元素
// 如果上传的文件大于4MB,需要将上传的文件按照4MB大小在本地切分成分片,不足4MB的分片自动成为最后一个分片,所有分片的md5值(32位小写)组成的字符串数组即为block_list
BlockList []string
// 文件命名策略
// 1 表示当path冲突时,进行重命名
// 2 表示当path冲突且block_list不同时,进行重命名
// 3 当云端存在同名文件时,对该文件进行覆盖
Rtype int32
// 上传ID
Uploadid string
// 文件MD5,32位小写
ContentMD5 string
// 文件校验段的MD5,32位小写,校验段对应文件前256KB
SliceMD5 string
// 客户端创建时间, 默认为当前时间戳
LocalCTime string
// 客户端修改时间,默认为当前时间戳
LocalMTime string
}
PreCreateFileReq 预上传请求参数 https://pan.baidu.com/union/doc/3ksg0s9r7 预上传是通知网盘云端新建一个上传任务,网盘云端返回唯一ID uploadid 来标识此上传任务。
func NewPreCreateFileReq ¶ added in v0.1.0
func NewPreCreateFileReq(path string, size int32, blockList []string) *PreCreateFileReq
PreCreateFileReq 预上传请求参数
func (*PreCreateFileReq) GetBlockListString ¶ added in v0.1.0
func (r *PreCreateFileReq) GetBlockListString() string
GetBlockListString 返回block_list的json字符串
func (*PreCreateFileReq) SetContentMD5 ¶ added in v0.1.0
func (r *PreCreateFileReq) SetContentMD5(contentMD5 string) *PreCreateFileReq
func (*PreCreateFileReq) SetLocalCTime ¶ added in v0.1.0
func (r *PreCreateFileReq) SetLocalCTime(localCTime string) *PreCreateFileReq
func (*PreCreateFileReq) SetLocalMTime ¶ added in v0.1.0
func (r *PreCreateFileReq) SetLocalMTime(localMTime string) *PreCreateFileReq
func (*PreCreateFileReq) SetRtype ¶ added in v0.1.0
func (r *PreCreateFileReq) SetRtype(rtype int32) *PreCreateFileReq
func (*PreCreateFileReq) SetSliceMD5 ¶ added in v0.1.0
func (r *PreCreateFileReq) SetSliceMD5(sliceMD5 string) *PreCreateFileReq
func (*PreCreateFileReq) SetUploadid ¶ added in v0.1.0
func (r *PreCreateFileReq) SetUploadid(uploadid string) *PreCreateFileReq
type PreCreateFileRes ¶ added in v0.1.0
type PreCreateFileRes struct {
ErrorRes
// 文件的绝对路径
Path string `json:"path,omitempty"`
// 上传唯一ID标识此上传任务
Uploadid string `json:"uploadid,omitempty"`
// 返回类型,系统内部状态字段
ReturnType int32 `json:"return_type,omitempty"`
// 需要上传的分片序号列表,索引从0开始
BlockList []int `json:"block_list,omitempty"`
// 请求ID
RequestId int64 `json:"request_id,omitempty"`
}
PreCreateFileRes 预上传响应参数
func PreCreateFile ¶ added in v0.1.0
func PreCreateFile(accessToken string, req *PreCreateFileReq) (*PreCreateFileRes, error)
预上传 https://pan.baidu.com/union/doc/3ksg0s9r7 预上传是通知网盘云端新建一个上传任务,网盘云端返回唯一ID uploadid 来标识此上传任务。
type SearchFileReq ¶
func NewSearchFileReq ¶
func NewSearchFileReq(path string) *SearchFileReq
type SearchFileRes ¶
func SearchFile ¶
func SearchFile(accessToken string, req *SearchFileReq) (*SearchFileRes, error)
搜索文件
type UploadFilePartReq ¶ added in v0.1.0
type UploadFilePartReq struct {
// 上传后使用的文件绝对路径,需要urlencode,需要与上一个阶段预上传precreate接口中的path保持一致
Path string
// 上一个阶段预上传precreate接口下发的uploadid
Uploadid string
// 文件分片的位置序号,从0开始,参考上一个阶段预上传precreate接口返回的block_list
Partseq int
// 固定值 tmpfile
Type string
// 要进行传送的本地文件分片
File *os.File
}
UploadFilePartReq 分片上传请求参数 https://pan.baidu.com/union/doc/nksg0s9vi 分片上传,这里是实际的文件内容传送部分。一般多为大于4MB的文件,需将文件以4MB为单位切分,对切分后得到的n个分片一一调用该接口进行传送。
func NewUploadFilePartReq ¶ added in v0.1.0
func NewUploadFilePartReq(path string, uploadid string, partseq int) *UploadFilePartReq
UploadFilePartReq 分片上传请求参数
type UploadFilePartRes ¶ added in v0.1.0
UploadFilePartRes 分片上传响应参数
func UploadFilePart ¶ added in v0.1.0
func UploadFilePart(accessToken string, req *UploadFilePartReq) (*UploadFilePartRes, error)
分片上传 https://pan.baidu.com/union/doc/nksg0s9vi 分片上传,这里是实际的文件内容传送部分。一般多为大于4MB的文件,需将文件以4MB为单位切分,对切分后得到的n个分片一一调用该接口进行传送。
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
get_file_list_all
command
|
|
|
get_login_need
command
|
|
|
rename
command
|
|
|
upload
command
|
|