baidupcs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package baidupcs BaiduPCS RESTful API 工具包

Index

Constants

View Source
const (
	// OperationGetUK 获取UK
	OperationGetUK = "获取UK"
	// OperationGetBDSToken
	OperationGetBDSToken = "获取bdstoken"
	// OperationGetCursorDiff
	OperationGetCursorDiff = "获取cursor后文件列表diff信息"
	// OperationQuotaInfo 获取当前用户空间配额信息
	OperationQuotaInfo = "获取当前用户空间配额信息"
	// OperationFilesDirectoriesMeta 获取文件/目录的元信息
	OperationFilesDirectoriesMeta = "获取文件/目录的元信息"
	// OperationFilesDirectoriesList 获取目录下的文件列表
	OperationFilesDirectoriesList = "获取目录下的文件列表"
	// OperationSearch 搜索
	OperationSearch = "搜索"
	// OperationRemove 删除文件/目录
	OperationRemove = "删除文件/目录"
	// OperationMkdir 创建目录
	OperationMkdir = "创建目录"
	// OperationRename 重命名文件/目录
	OperationRename = "重命名文件/目录"
	// OperationCopy 拷贝文件/目录
	OperationCopy = "拷贝文件/目录"
	// OperationMove 移动文件/目录
	OperationMove = "移动文件/目录"
	// OperationRapidUpload 秒传文件
	OperationRapidUpload = "秒传文件"
	// OperationUpload 上传单个文件
	OperationUpload = "上传单个文件"
	// OperationUploadTmpFile 分片上传—文件分片及上传
	OperationUploadTmpFile = "分片上传—文件分片及上传"
	// OperationUploadCreateSuperFile 分片上传—合并分片文件
	OperationUploadCreateSuperFile = "分片上传—合并分片文件"
	// OperationUploadPrecreate 分片上传—Precreate
	OperationUploadPrecreate = "分片上传—Precreate"
	// OperationUploadSuperfile2 分片上传—Superfile2
	OperationUploadSuperfile2 = "分片上传—Superfile2"
	// OperationDownloadFile 下载单个文件
	OperationDownloadFile = "下载单个文件"
	// OperationDownloadStreamFile 下载流式文件
	OperationDownloadStreamFile = "下载流式文件"
	// OperationLocateDownload 获取下载链接
	OperationLocateDownload = "获取下载链接"
	// OperationLocatePanAPIDownload 从百度网盘首页获取下载链接
	OperationLocatePanAPIDownload = "获取下载链接2"
	// OperationCloudDlAddTask 添加离线下载任务
	OperationCloudDlAddTask = "添加离线下载任务"
	// OperationCloudDlQueryTask 精确查询离线下载任务
	OperationCloudDlQueryTask = "精确查询离线下载任务"
	// OperationCloudDlListTask 查询离线下载任务列表
	OperationCloudDlListTask = "查询离线下载任务列表"
	// OperationCloudDlCancelTask 取消离线下载任务
	OperationCloudDlCancelTask = "取消离线下载任务"
	// OperationCloudDlDeleteTask 删除离线下载任务
	OperationCloudDlDeleteTask = "删除离线下载任务"
	// OperationCloudDlClearTask 清空离线下载任务记录
	OperationCloudDlClearTask = "清空离线下载任务记录"
	// OperationShareSet 创建分享链接
	OperationShareSet = "创建分享链接"
	// OperationShareCancel 取消分享
	OperationShareCancel = "取消分享"
	// OperationShareList 列出分享列表
	OperationShareList = "列出分享列表"
	// OperationShareSURLInfo 获取分享详细信息
	OperationShareSURLInfo = "获取分享详细信息"
	// OperationShareFileSavetoLocal 分享链接转存到网盘
	OperationShareFileSavetoLocal = "分享链接转存到网盘"
	// OperationRapidLinkSavetoLocal 秒传链接转存到网盘
	OperationRapidLinkSavetoLocal = "秒传链接转存到网盘"
	// OperationRecycleList 列出回收站文件列表
	OperationRecycleList = "列出回收站文件列表"
	// OperationRecycleRestore 还原回收站文件或目录
	OperationRecycleRestore = "还原回收站文件或目录"
	// OperationRecycleDelete 删除回收站文件或目录
	OperationRecycleDelete = "删除回收站文件或目录"
	// OperationRecycleClear 清空回收站
	OperationRecycleClear = "清空回收站"

	// OperationExportFileInfo 导出文件信息
	OperationExportFileInfo = "导出文件信息"
	// OperationGetRapidUploadInfo 获取文件秒传信息
	OperationGetRapidUploadInfo = "获取文件秒传信息"
	// OperationFixMD5 修复文件md5
	OperationFixMD5 = "修复文件md5"
	// OperrationMatchPathByShellPattern 通配符匹配文件路径
	OperrationMatchPathByShellPattern = "通配符匹配文件路径"

	// PCSBaiduCom pcs api地址
	PCSBaiduCom = "pcs.baidu.com"
	// PanBaiduCom 网盘首页api地址
	PanBaiduCom = "pan.baidu.com"
	// YunBaiduCom 网盘首页api地址2
	YunBaiduCom = "yun.baidu.com"
	// PanAppID 百度网盘appid
	PanAppID = "250528"
	// NetdiskUA 网盘客户端ua
	NetdiskUA = "netdisk;P2SP;3.0.0.8;netdisk;11.12.3;ANG-AN00;android-android;10.0;JSbridge4.4.0;jointBridge;1.1.0;"
	// DotBaiduCom .baidu.com
	DotBaiduCom = ".baidu.com"
	// PathSeparator 路径分隔符
	PathSeparator = "/"
)
View Source
const (
	// OrderByName 根据文件名排序
	OrderByName OrderBy = "name"
	// OrderByTime 根据时间排序
	OrderByTime OrderBy = "time"
	// OrderBySize 根据大小排序, 注意目录无大小
	OrderBySize OrderBy = "size"
	// OrderAsc 升序
	OrderAsc Order = "asc"
	// OrderDesc 降序
	OrderDesc Order = "desc"
)
View Source
const (
	// MaxUploadBlockSize 最大上传的文件分片大小
	MaxUploadBlockSize = 2 * converter.GB
	// MinUploadBlockSize 最小的上传的文件分片大小
	MinUploadBlockSize = 4 * converter.MB
	// MaxRapidUploadSize 秒传文件支持的最大文件大小
	MaxRapidUploadSize = 20 * converter.GB
	// RecommendUploadBlockSize 推荐的上传的文件分片大小
	RecommendUploadBlockSize = 1 * converter.GB
	// SliceMD5Size 计算 slice-md5 所需的长度
	SliceMD5Size = 256 * converter.KB
	// EmptyContentMD5 空串的md5
	EmptyContentMD5 = "d41d8cd98f00b204e9800998ecf8427e"
)
View Source
const (
	// ShellPatternCharacters 通配符字符串
	ShellPatternCharacters = "*?[]"
)

Variables

View Source
var (
	// ErrLocateDownloadURLNotFound 未找到下载链接
	ErrLocateDownloadURLNotFound = errors.New("locatedownload url not found")
	// InitRangeSize 初次请求的片段值
	InitRangeSize = 32 * converter.KB
)
View Source
var (
	// ErrFixMD5Isdir 目录不需要修复md5
	ErrFixMD5Isdir = errors.New("directory not support fix md5")
	// ErrFixMD5Failed 修复MD5失败, 可能服务器未刷新
	ErrFixMD5Failed = errors.New("fix md5 failed")
	// ErrFixMD5FileInfoNil 文件信息对象为空
	ErrFixMD5FileInfoNil = errors.New("file info is nil")
	// ErrMatchPathByShellPatternNotAbsPath 不是绝对路径
	ErrMatchPathByShellPatternNotAbsPath = errors.New("not absolute path")

	ErrContentRangeNotFound               = errors.New("Content-Range not found")
	ErrGetRapidUploadInfoLengthNotFound   = errors.New("Content-Length not found")
	ErrGetRapidUploadInfoMD5NotFound      = errors.New("Content-MD5 not found")
	ErrGetRapidUploadInfoCrc32NotFound    = errors.New("x-bs-meta-crc32 not found")
	ErrGetRapidUploadInfoFilenameNotEqual = errors.New("文件名不匹配")
	ErrGetRapidUploadInfoLengthNotEqual   = errors.New("Content-Length 不匹配")
	ErrGetRapidUploadInfoMD5NotEqual      = errors.New("Content-MD5 不匹配")
	ErrGetRapidUploadInfoCrc32NotEqual    = errors.New("x-bs-meta-crc32 不匹配")
	ErrGetRapidUploadInfoSliceMD5NotEqual = errors.New("slice-md5 不匹配")

	ErrFileTooLarge = errors.New("文件大于20GB, 无法秒传")
)
View Source
var (
	// ErrUploadMD5NotFound 未找到md5
	ErrUploadMD5NotFound = errors.New("unknown response data, md5 not found")
	// ErrUploadSavePathFound 未找到保存路径
	ErrUploadSavePathFound = errors.New("unknown response data, file saved path not found")
	// ErrUploadSeqNotMatch 服务器返回的上传队列不匹配
	ErrUploadSeqNotMatch = errors.New("服务器返回的上传队列不匹配")
	// ErrUploadMD5Unknown 服务器无匹配文件/秒传未生效
	ErrUploadMD5Unknown = errors.New("服务器无匹配文件/秒传未生效")
	// ErrUploadFileExists 文件或目录已存在
	ErrUploadFileExists = errors.New("文件已存在")
)
View Source
var (
	// DefaultOrderOptions 默认的排序
	DefaultOrderOptions = &OrderOptions{
		By:    OrderByName,
		Order: OrderAsc,
	}
)
View Source
var (
	// ErrNilJSONValue 解析出的json值为空
	ErrNilJSONValue = errors.New("json value is nil")
)
View Source
var (
	// ErrShareLinkNotFound 未找到分享链接
	ErrShareLinkNotFound = errors.New("未找到分享链接")
)
View Source
var PublicSuffixList cookiejar.PublicSuffixList = list{}

PublicSuffixList baidupcs PublicSuffixList

Functions

func CreatePasswd

func CreatePasswd() string

func DecryptMD5

func DecryptMD5(rawMD5 string) string

func GetHTTPScheme

func GetHTTPScheme(https bool) (scheme string)

GetHTTPScheme 获取 http 协议, https 或 http

Types

type APIDownloadDlinkInfo

type APIDownloadDlinkInfo struct {
	Dlink string `json:"dlink"`
	FsID  string `json:"fs_id"`
}

APIDownloadDlinkInfo 下载信息

type APIDownloadDlinkInfoList

type APIDownloadDlinkInfoList []*APIDownloadDlinkInfo

APIDownloadDlinkInfoList 下载信息列表

type BaiduPCS

type BaiduPCS struct {
	// contains filtered or unexported fields
}

BaiduPCS 百度 PCS API 详情

func NewPCS

func NewPCS(appID int, bduss string) *BaiduPCS

NewPCS 提供app_id, 百度BDUSS, 返回 BaiduPCS 对象

func NewPCSWithClient

func NewPCSWithClient(appID int, client *requester.HTTPClient) *BaiduPCS

NewPCSWithClient 提供app_id, 自定义客户端, 返回 BaiduPCS 对象

func NewPCSWithCookieStr

func NewPCSWithCookieStr(appID int, cookieStr string) *BaiduPCS

NewPCSWithCookieStr 提供app_id, cookie 字符串, 返回 BaiduPCS 对象

func (*BaiduPCS) APIRapidUpload

func (pcs *BaiduPCS) APIRapidUpload(targetPath, contentMD5, sliceMD5, crc32 string, length int64) (pcsError pcserror.Error)

APIRapidUpload openapi秒传文件

func (*BaiduPCS) AccessSharePage

func (pcs *BaiduPCS) AccessSharePage(featurestr string, first bool) (tokens map[string]string)

func (*BaiduPCS) BDSToken

func (pcs *BaiduPCS) BDSToken() (bdstoken string, pcsError pcserror.Error)

func (*BaiduPCS) CacheFilesDirectoriesList

func (pcs *BaiduPCS) CacheFilesDirectoriesList(path string, options *OrderOptions) (fdl FileDirectoryList, pcsError pcserror.Error)

CacheFilesDirectoriesList 缓存获取

func (*BaiduPCS) CheckIsdir

func (pcs *BaiduPCS) CheckIsdir(op string, targetPath string, policy string, fileSize int64) pcserror.Error

func (*BaiduPCS) CloudDlAddTask

func (pcs *BaiduPCS) CloudDlAddTask(sourceURL, savePath string) (taskID int64, pcsError pcserror.Error)

CloudDlAddTask 添加离线下载任务

func (*BaiduPCS) CloudDlCancelTask

func (pcs *BaiduPCS) CloudDlCancelTask(taskID int64) (pcsError pcserror.Error)

CloudDlCancelTask 取消离线下载任务

func (*BaiduPCS) CloudDlClearTask

func (pcs *BaiduPCS) CloudDlClearTask() (total int, pcsError pcserror.Error)

CloudDlClearTask 清空离线下载任务记录

func (*BaiduPCS) CloudDlDeleteTask

func (pcs *BaiduPCS) CloudDlDeleteTask(taskID int64) (pcsError pcserror.Error)

CloudDlDeleteTask 删除离线下载任务

func (*BaiduPCS) CloudDlListTask

func (pcs *BaiduPCS) CloudDlListTask() (cl CloudDlTaskList, pcsError pcserror.Error)

CloudDlListTask 查询离线下载任务列表

func (*BaiduPCS) CloudDlQueryTask

func (pcs *BaiduPCS) CloudDlQueryTask(taskIDs []int64) (cl CloudDlTaskList, pcsError pcserror.Error)

CloudDlQueryTask 精确查询离线下载任务

func (*BaiduPCS) Copy

func (pcs *BaiduPCS) Copy(cpmvJSON ...*CpMvJSON) (pcsError pcserror.Error)

Copy 批量拷贝文件/目录

func (*BaiduPCS) DownloadFile

func (pcs *BaiduPCS) DownloadFile(path string, downloadFunc DownloadFunc) (err error)

DownloadFile 下载单个文件

func (*BaiduPCS) DownloadStreamFile

func (pcs *BaiduPCS) DownloadStreamFile(path string, downloadFunc DownloadFunc) (err error)

DownloadStreamFile 下载流式文件

func (*BaiduPCS) ExportByFileInfo

func (pcs *BaiduPCS) ExportByFileInfo(finfo *FileDirectory) (rinfo *RapidUploadInfo, pcsError pcserror.Error)

ExportByFileInfo 通过文件信息对象, 导出文件信息

func (*BaiduPCS) ExtractShareInfo

func (pcs *BaiduPCS) ExtractShareInfo(metajsonstr string) (res map[string]string)

func (*BaiduPCS) FilesDirectoriesBatchMeta

func (pcs *BaiduPCS) FilesDirectoriesBatchMeta(paths ...string) (data FileDirectoryList, pcsError pcserror.Error)

FilesDirectoriesBatchMeta 获取多个文件/目录的元信息

func (*BaiduPCS) FilesDirectoriesList

func (pcs *BaiduPCS) FilesDirectoriesList(path string, options *OrderOptions) (data FileDirectoryList, pcsError pcserror.Error)

FilesDirectoriesList 获取目录下的文件和目录列表

func (*BaiduPCS) FilesDirectoriesMeta

func (pcs *BaiduPCS) FilesDirectoriesMeta(path string) (data *FileDirectory, pcsError pcserror.Error)

FilesDirectoriesMeta 获取单个文件/目录的元信息

func (*BaiduPCS) FilesDirectoriesRecurseList

func (pcs *BaiduPCS) FilesDirectoriesRecurseList(path string, options *OrderOptions, handleFileDirectoryFunc HandleFileDirectoryFunc) (data FileDirectoryList)

FilesDirectoriesRecurseList 递归获取目录下的文件和目录列表

func (*BaiduPCS) FixMD5

func (pcs *BaiduPCS) FixMD5(pcspath string) (pcsError pcserror.Error)

FixMD5 尝试修复文件的md5

func (*BaiduPCS) FixMD5ByFileInfo

func (pcs *BaiduPCS) FixMD5ByFileInfo(finfo *FileDirectory) (pcsError pcserror.Error)

FixMD5ByFileInfo 尝试修复文件的md5, 通过文件信息对象

func (*BaiduPCS) GenerateRequestQuery

func (pcs *BaiduPCS) GenerateRequestQuery(mode string, params map[string]string) (res map[string]string)

func (*BaiduPCS) GenerateShareQueryURL

func (pcs *BaiduPCS) GenerateShareQueryURL(subPath string, params map[string]string) *url.URL

func (*BaiduPCS) GetBAIDUID

func (pcs *BaiduPCS) GetBAIDUID() (baiduid string)

GetBAIDUID 获取BAIDUID

func (*BaiduPCS) GetBDUSS

func (pcs *BaiduPCS) GetBDUSS() (bduss string)

GetBDUSS 获取BDUSS

func (*BaiduPCS) GetClient

func (pcs *BaiduPCS) GetClient() *requester.HTTPClient

GetClient 获取当前的http client

func (pcs *BaiduPCS) GetDirectDownloadLink(path string) (link string, pcsError pcserror.Error)

GetDirectDownloadLink 根据method=download方法获取下载链接, 能获取到新上传文件的信息, 作为常规秒传的备选方案

func (*BaiduPCS) GetRapidUploadInfoByFileInfo

func (pcs *BaiduPCS) GetRapidUploadInfoByFileInfo(finfo *FileDirectory) (rinfo *RapidUploadInfo, pcsError pcserror.Error)

GetRapidUploadInfoByFileInfo 通过文件信息对象, 获取秒传信息

func (pcs *BaiduPCS) GetRapidUploadInfoByLink(link string, compareRInfo *RapidUploadInfo) (rinfo *RapidUploadInfo, pcsError pcserror.Error)

GetRapidUploadInfoByLink 通过下载链接, 获取文件秒传信息

func (*BaiduPCS) Isdir

func (pcs *BaiduPCS) Isdir(pcspath string) (fileSize int64, isdir bool, pcsError pcserror.Error)

Isdir 检查路径在网盘中是否为目录

func (*BaiduPCS) LocateDownload

func (pcs *BaiduPCS) LocateDownload(pcspath string) (info *URLInfo, pcsError pcserror.Error)

LocateDownloadWithUserAgent 获取下载链接

func (*BaiduPCS) LocatePanAPIDownload

func (pcs *BaiduPCS) LocatePanAPIDownload(fidList ...int64) (dlinkInfoList APIDownloadDlinkInfoList, pcsError pcserror.Error)

LocatePanAPIDownload 从百度网盘首页获取下载链接

func (*BaiduPCS) MatchPathByShellPattern

func (pcs *BaiduPCS) MatchPathByShellPattern(pattern string) (pcspaths []string, pcsError pcserror.Error)

MatchPathByShellPattern 通配符匹配文件路径, pattern 为绝对路径

func (*BaiduPCS) Mkdir

func (pcs *BaiduPCS) Mkdir(pcspath string) (pcsError pcserror.Error)

Mkdir 创建目录

func (*BaiduPCS) Move

func (pcs *BaiduPCS) Move(cpmvJSON ...*CpMvJSON) (pcsError pcserror.Error)

Move 批量移动文件/目录

func (*BaiduPCS) PostShareQuery

func (pcs *BaiduPCS) PostShareQuery(url string, referer string, data map[string]string) (res map[string]string)

func (*BaiduPCS) PrepareBDStoken

func (pcs *BaiduPCS) PrepareBDStoken() (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

func (*BaiduPCS) PrepareCloudDlAddTask

func (pcs *BaiduPCS) PrepareCloudDlAddTask(sourceURL, savePath string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCloudDlAddTask 添加离线下载任务, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareCloudDlCancelTask

func (pcs *BaiduPCS) PrepareCloudDlCancelTask(taskID int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCloudDlCancelTask 取消离线下载任务, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareCloudDlClearTask

func (pcs *BaiduPCS) PrepareCloudDlClearTask() (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCloudDlClearTask 清空离线下载任务记录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareCloudDlDeleteTask

func (pcs *BaiduPCS) PrepareCloudDlDeleteTask(taskID int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCloudDlDeleteTask 取消离线下载任务, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareCloudDlListTask

func (pcs *BaiduPCS) PrepareCloudDlListTask() (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCloudDlListTask 查询离线下载任务列表, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareCloudDlQueryTask

func (pcs *BaiduPCS) PrepareCloudDlQueryTask(taskIDs string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCloudDlQueryTask 精确查询离线下载任务, 只返回服务器响应数据和错误信息, taskids 例子: 12123,234234,2344, 用逗号隔开多个 task_id

func (*BaiduPCS) PrepareCopy

func (pcs *BaiduPCS) PrepareCopy(cpmvJSON ...*CpMvJSON) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareCopy 批量拷贝文件/目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareFilesDirectoriesBatchMeta

func (pcs *BaiduPCS) PrepareFilesDirectoriesBatchMeta(paths ...string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareFilesDirectoriesBatchMeta 获取多个文件/目录的元信息, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareFilesDirectoriesDiff

func (pcs *BaiduPCS) PrepareFilesDirectoriesDiff(cursor string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

func (*BaiduPCS) PrepareFilesDirectoriesList

func (pcs *BaiduPCS) PrepareFilesDirectoriesList(path string, options *OrderOptions) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareFilesDirectoriesList 获取目录下的文件和目录列表, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareLocateDownload

func (pcs *BaiduPCS) PrepareLocateDownload(pcspath string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareLocateDownload 获取下载链接, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareLocatePanAPIDownload

func (pcs *BaiduPCS) PrepareLocatePanAPIDownload(fidList ...int64) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareLocatePanAPIDownload 从百度网盘首页获取下载链接, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareMkdir

func (pcs *BaiduPCS) PrepareMkdir(pcspath string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareMkdir 创建目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareMove

func (pcs *BaiduPCS) PrepareMove(cpmvJSON ...*CpMvJSON) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareMove 批量移动文件/目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareQuotaInfo

func (pcs *BaiduPCS) PrepareQuotaInfo() (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareQuotaInfo 获取当前用户空间配额信息, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRapidUpload

func (pcs *BaiduPCS) PrepareRapidUpload(targetPath, contentMD5, sliceMD5, crc32 string, length int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareRapidUpload 秒传文件旧接口, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRapidUploadV2

func (pcs *BaiduPCS) PrepareRapidUploadV2(targetPath, contentMD5, sliceMD5, dataContent, crc32 string, offset, length, totalSize, dataTime int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareRapidUploadV2 秒传文件新接口, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRecycleClear

func (pcs *BaiduPCS) PrepareRecycleClear() (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareRecycleClear 清空回收站, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRecycleDelete

func (pcs *BaiduPCS) PrepareRecycleDelete(fidList ...int64) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareRecycleDelete 删除回收站文件或目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRecycleList

func (pcs *BaiduPCS) PrepareRecycleList(page int) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareRecycleList 列出回收站文件列表, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRecycleRestore

func (pcs *BaiduPCS) PrepareRecycleRestore(fidList ...int64) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareRecycleRestore 还原回收站文件或目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRemove

func (pcs *BaiduPCS) PrepareRemove(paths ...string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareRemove 批量删除文件/目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareRename

func (pcs *BaiduPCS) PrepareRename(from, to string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareRename 重命名文件/目录, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareSearch

func (pcs *BaiduPCS) PrepareSearch(targetPath, keyword string, recursive bool) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareSearch 按文件名搜索文件, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareShareCancel

func (pcs *BaiduPCS) PrepareShareCancel(shareIDs []int64) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareShareCancel 取消分享, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareShareList

func (pcs *BaiduPCS) PrepareShareList(page int) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareShareList 列出分享列表, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareSharePSet

func (pcs *BaiduPCS) PrepareSharePSet(paths []string, pwd string, period int) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareSharePSet 私密分享文件, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareShareSURLInfo

func (pcs *BaiduPCS) PrepareShareSURLInfo(shareID int64) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareShareSURLInfo 获取分享的详细信息, 包含密码, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareUK

func (pcs *BaiduPCS) PrepareUK() (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareUK 获取用户 UK, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareUpload

func (pcs *BaiduPCS) PrepareUpload(policy string, targetPath string, uploadFunc UploadFunc) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareUpload 上传单个文件, 只返回服务器响应数据和错误信息(分片上传中的预上传部分)

func (*BaiduPCS) PrepareUploadCreateSuperFile

func (pcs *BaiduPCS) PrepareUploadCreateSuperFile(policy string, checkDir bool, targetPath string, blockList ...string) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareUploadCreateSuperFile 分片上传—合并分片文件, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareUploadPrecreate

func (pcs *BaiduPCS) PrepareUploadPrecreate(targetPath, contentMD5, sliceMD5, crc32 string, size int64, bolckList ...string) (dataReadCloser io.ReadCloser, panError pcserror.Error)

PrepareUploadPrecreate 分片上传—Precreate, 只返回服务器响应数据和错误信息

func (*BaiduPCS) PrepareUploadSuperfile2

func (pcs *BaiduPCS) PrepareUploadSuperfile2(uploadid, targetPath string, partseq int, partOffset int64, uploadFunc UploadFunc) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareUploadSuperfile2 另一个上传接口

func (*BaiduPCS) PrepareUploadTmpFile

func (pcs *BaiduPCS) PrepareUploadTmpFile(uploadFunc UploadFunc) (dataReadCloser io.ReadCloser, pcsError pcserror.Error)

PrepareUploadTmpFile 分片上传—文件分片及上传, 只返回服务器响应数据和错误信息

func (*BaiduPCS) QuotaInfo

func (pcs *BaiduPCS) QuotaInfo() (quota, used int64, pcsError pcserror.Error)

QuotaInfo 获取当前用户空间配额信息

func (*BaiduPCS) RapidUpload

func (pcs *BaiduPCS) RapidUpload(targetPath, contentMD5, sliceMD5, dataContent, crc32 string, offset, length, totalSize, dataTime int64) (pcsError pcserror.Error)

RapidUpload 秒传文件

func (*BaiduPCS) RapidUploadNoCheckDir

func (pcs *BaiduPCS) RapidUploadNoCheckDir(targetPath, contentMD5, sliceMD5, crc32 string, length int64) (pcsError pcserror.Error)

RapidUploadNoCheckDir 秒传文件, 不进行目录检查, 会覆盖掉同名的目录!

func (*BaiduPCS) RecycleClear

func (pcs *BaiduPCS) RecycleClear() (sussNum int, pcsError pcserror.Error)

RecycleClear 清空回收站

func (*BaiduPCS) RecycleDelete

func (pcs *BaiduPCS) RecycleDelete(fidList ...int64) (panError pcserror.Error)

RecycleDelete 删除回收站文件或目录

func (*BaiduPCS) RecycleList

func (pcs *BaiduPCS) RecycleList(page int) (fdl RecycleFDInfoList, panError pcserror.Error)

RecycleList 列出回收站文件列表

func (*BaiduPCS) RecycleRestore

func (pcs *BaiduPCS) RecycleRestore(fidList ...int64) (sussFsIDList []*FsIDJSON, pcsError pcserror.Error)

RecycleRestore 还原回收站文件或目录

func (*BaiduPCS) Remove

func (pcs *BaiduPCS) Remove(paths ...string) (pcsError pcserror.Error)

Remove 批量删除文件/目录

func (*BaiduPCS) Rename

func (pcs *BaiduPCS) Rename(from, to string) (pcsError pcserror.Error)

Rename 重命名文件/目录

func (*BaiduPCS) Search

func (pcs *BaiduPCS) Search(targetPath, keyword string, recursive bool) (fdl FileDirectoryList, pcsError pcserror.Error)

Search 按文件名搜索文件, 不支持查找目录

func (*BaiduPCS) SetAPPID

func (pcs *BaiduPCS) SetAPPID(appID int)

SetAPPID 设置app_id

func (*BaiduPCS) SetHTTPS

func (pcs *BaiduPCS) SetHTTPS(https bool)

SetHTTPS 是否启用https连接

func (*BaiduPCS) SetPCSAddr

func (pcs *BaiduPCS) SetPCSAddr(addr string)

SetPCSAddr 设置 PCS 服务器地址

func (*BaiduPCS) SetPCSUserAgent

func (pcs *BaiduPCS) SetPCSUserAgent(ua string)

SetPCSUserAgent 设置 PCS User-Agent

func (*BaiduPCS) SetPanUserAgent

func (pcs *BaiduPCS) SetPanUserAgent(ua string)

SetPanUserAgent 设置 Pan User-Agent

func (*BaiduPCS) SetSboxtkn

func (pcs *BaiduPCS) SetSboxtkn(sboxtkn string)

SetSboxtkn 设置sboxtkn

func (*BaiduPCS) SetStoken

func (pcs *BaiduPCS) SetStoken(stoken string)

SetStoken 设置stoken

func (*BaiduPCS) SetUID

func (pcs *BaiduPCS) SetUID(uid uint64)

SetUID 设置百度UID 只有locatedownload才需要设置此项

func (*BaiduPCS) SetaccessToken

func (pcs *BaiduPCS) SetaccessToken(accessToken string)

SetaccessToken 设置秒传转存用的accesstoken

func (*BaiduPCS) ShareCancel

func (pcs *BaiduPCS) ShareCancel(shareIDs []int64) (pcsError pcserror.Error)

ShareCancel 取消分享

func (*BaiduPCS) ShareList

func (pcs *BaiduPCS) ShareList(page int) (records ShareRecordInfoList, pcsError pcserror.Error)

ShareList 列出分享列表

func (*BaiduPCS) ShareSURLInfo

func (pcs *BaiduPCS) ShareSURLInfo(shareID int64) (info *ShareSURLInfo, pcsError pcserror.Error)

ShareSURLInfo 获取分享的详细信息, 包含密码

func (*BaiduPCS) ShareSet

func (pcs *BaiduPCS) ShareSet(paths []string, option *ShareOption) (s *Shared, pcsError pcserror.Error)

ShareSet 分享文件

func (*BaiduPCS) SuperTransfer

func (pcs *BaiduPCS) SuperTransfer(params map[string]string, limit string)

func (*BaiduPCS) UK

func (pcs *BaiduPCS) UK() (uk int64, pcsError pcserror.Error)

UK 获取用户 UK

func (*BaiduPCS) URL

func (pcs *BaiduPCS) URL() *url.URL

URL 返回 url

func (*BaiduPCS) UpdatePCSCookies

func (pcs *BaiduPCS) UpdatePCSCookies(reverse bool)

UpdatePCSCookies 去除重名Cookies, 同名cookeis只保留最新的

func (*BaiduPCS) Upload

func (pcs *BaiduPCS) Upload(policy, targetPath string, uploadFunc UploadFunc) (pcsError pcserror.Error, newpath string)

Upload 上传单个文件

func (*BaiduPCS) UploadCreateSuperFile

func (pcs *BaiduPCS) UploadCreateSuperFile(policy string, checkDir bool, targetPath string, blockList ...string) (pcsError pcserror.Error)

UploadCreateSuperFile 分片上传—合并分片文件

func (*BaiduPCS) UploadPrecreate

func (pcs *BaiduPCS) UploadPrecreate(targetPath, contentMD5, sliceMD5, crc32 string, size int64, bolckList ...string) (precreateInfo *PrecreateInfo, pcsError pcserror.Error)

UploadPrecreate 分片上传—Precreate, 支持检验秒传

func (*BaiduPCS) UploadSuperfile2

func (pcs *BaiduPCS) UploadSuperfile2(uploadid, targetPath string, partseq int, partOffset int64, uploadFunc UploadFunc) (md5sum string, pcsError pcserror.Error)

UploadSuperfile2 分片上传—Superfile2

func (*BaiduPCS) UploadTmpFile

func (pcs *BaiduPCS) UploadTmpFile(uploadFunc UploadFunc) (md5 string, pcsError pcserror.Error)

UploadTmpFile 分片上传—文件分片及上传

type BlockListJSON

type BlockListJSON struct {
	BlockList []string `json:"block_list"`
}

BlockListJSON 文件分块信息JSON

type CloudDlFileInfo

type CloudDlFileInfo struct {
	FileName string `json:"file_name"`
	FileSize int64  `json:"file_size"`
}

CloudDlFileInfo 离线下载的文件信息

type CloudDlTaskInfo

type CloudDlTaskInfo struct {
	TaskID       int64
	Status       int // 0下载成功, 1下载进行中, 2系统错误, 3资源不存在, 4下载超时, 5资源存在但下载失败, 6存储空间不足, 7任务取消
	StatusText   string
	FileSize     int64  // 文件大小
	FinishedSize int64  // 文件大小
	CreateTime   int64  // 创建时间
	StartTime    int64  // 开始时间
	FinishTime   int64  // 结束时间
	SavePath     string // 保存的路径
	SourceURL    string // 资源地址
	TaskName     string // 任务名称, 一般为文件名
	OdType       int
	FileList     []*CloudDlFileInfo
	Result       int // 0查询成功,结果有效,1要查询的task_id不存在
}

CloudDlTaskInfo 离线下载的任务信息

func (*CloudDlTaskInfo) ParseText

func (ci *CloudDlTaskInfo) ParseText()

ParseText 解析状态码

type CloudDlTaskList

type CloudDlTaskList []*CloudDlTaskInfo

CloudDlTaskList 离线下载的任务信息列表

func (CloudDlTaskList) String

func (cl CloudDlTaskList) String() string

type CpMvJSON

type CpMvJSON struct {
	From string `json:"from"` // 源文件或目录
	To   string `json:"to"`   // 目标文件或目录
}

CpMvJSON 源文件目录的地址和目标文件目录的地址

func (*CpMvJSON) JSON

func (cj *CpMvJSON) JSON() (data []byte, err error)

JSON json 数据构造

type CpMvJSONList

type CpMvJSONList []*CpMvJSON

CpMvJSONList CpMvJSON 列表

func (*CpMvJSONList) AllRelatedDir

func (cjl *CpMvJSONList) AllRelatedDir() (dirs []string)

AllRelatedDir 获取所有相关的目录

type CpMvListJSON

type CpMvListJSON struct {
	List CpMvJSONList `json:"list"`
}

CpMvListJSON []*CpMvJSON 对象数组

func (*CpMvListJSON) JSON

func (clj *CpMvListJSON) JSON() (data []byte, err error)

JSON json 数据构造

func (*CpMvListJSON) String

func (clj *CpMvListJSON) String() string

type DownloadFunc

type DownloadFunc func(downloadURL string, jar http.CookieJar) error

DownloadFunc 下载文件处理函数

type FileDirectory

type FileDirectory struct {
	FsID     int64  // fs_id
	AppID    int64  // app_id
	Path     string // 路径
	Filename string // 文件名 或 目录名
	Ctime    int64  // 创建日期
	Mtime    int64  // 修改日期
	MD5      string // md5 值
	BlockListJSON
	Size        int64  // 文件大小 (目录为0)
	Isdir       bool   // 是否为目录
	Ifhassubdir bool   // 是否含有子目录 (只对目录有效)
	PreBase     string // 真正的base目录

	Parent   *FileDirectory    // 父目录信息
	Children FileDirectoryList // 子目录信息
}

FileDirectory 文件或目录的元信息

func (*FileDirectory) String

func (f *FileDirectory) String() string

type FileDirectoryList

type FileDirectoryList []*FileDirectory

FileDirectoryList FileDirectory 的 指针数组

func (FileDirectoryList) AllFilePaths

func (fl FileDirectoryList) AllFilePaths() (pcspaths []string)

AllFilePaths 返回所有的网盘路径, 包括子目录

func (FileDirectoryList) Count

func (fl FileDirectoryList) Count() (fileN, directoryN int64)

Count 获取文件总数和目录总数

func (FileDirectoryList) TotalSize

func (fl FileDirectoryList) TotalSize() int64

TotalSize 获取目录下文件的总大小

type FsIDJSON

type FsIDJSON struct {
	FsID int64 `json:"fs_id"` // fs_id
}

FsIDJSON 文件或目录ID

type FsIDListJSON

type FsIDListJSON struct {
	List []*FsIDJSON `json:"list"`
}

FsIDListJSON fs_id 列表

type HandleFileDirectoryFunc

type HandleFileDirectoryFunc func(depth int, fdPath string, fd *FileDirectory, pcsError pcserror.Error) bool

HandleFileDirectoryFunc 处理文件或目录的元信息, 返回值控制是否退出递归

type LocateDownloadInfoV1

type LocateDownloadInfoV1 struct {
	Server []string `json:"server"`
	PathJSON
}

LocateDownloadInfoV1 locatedownload api v1

type Order

type Order string

Order 升序降序

type OrderBy

type OrderBy string

OrderBy 排序字段

type OrderOptions

type OrderOptions struct {
	By    OrderBy
	Order Order
}

OrderOptions 列文件/目录可选项

type PathJSON

type PathJSON struct {
	Path string `json:"path"`
}

PathJSON 网盘路径

type PathsListJSON

type PathsListJSON struct {
	List []*PathJSON `json:"list"`
}

PathsListJSON 网盘路径列表

func (*PathsListJSON) JSON

func (plj *PathsListJSON) JSON(paths ...string) (data []byte, err error)

JSON json 数据构造

type PrecreateInfo

type PrecreateInfo struct {
	IsRapidUpload bool
	UploadID      string
	UploadSeqList []*UploadSeq
}

PrecreateInfo 预提交文件消息返回数据

type RapidUploadInfo

type RapidUploadInfo struct {
	Filename      string
	ContentLength int64
	ContentMD5    string
	SliceMD5      string
	ContentCrc32  string
}

RapidUploadInfo 文件秒传信息

type RecycleClearInfo

type RecycleClearInfo struct {
	List    RecycleFDInfoList `json:"list"`
	SussNum int               `json:"succNum"`
}

RecycleClearInfo 清空回收站的信息

type RecycleFDInfo

type RecycleFDInfo struct {
	FsID     int64  `json:"fs_id"` // fs_id
	Isdir    int    `json:"isdir"`
	LeftTime int    `json:"leftTime"`        // 剩余时间
	Path     string `json:"path"`            // 路径
	Filename string `json:"server_filename"` // 文件名 或 目录名
	Ctime    int64  `json:"server_ctime"`    // 创建日期
	Mtime    int64  `json:"server_mtime"`    // 修改日期
	MD5      string `json:"md5"`             // md5 值
	Size     int64  `json:"size"`            // 文件大小 (目录为0)
}

RecycleFDInfo 回收站中文件/目录信息

type RecycleFDInfoList

type RecycleFDInfoList []*RecycleFDInfo

RecycleFDInfoList 回收站中文件/目录列表

type ShareOption

type ShareOption struct {
	Password   string // 密码
	Period     int    // 有效期
	IsCombined bool   // 是否将密码输出到分享链接
}

ShareOption 分享可选项

type ShareRecordInfo

type ShareRecordInfo struct {
	ShareID         int64   `json:"shareId"`
	FsIds           []int64 `json:"fsIds"`
	Passwd          string  `json:"-"` // 这个字段已经没有用了, 需要从ShareSURLInfo中获取
	Shortlink       string  `json:"shortlink"`
	Status          int     `json:"status"`          // 状态
	Public          int     `json:"public"`          // 是否为公开分享
	TypicalCategory int     `json:"typicalCategory"` // 文件类型
	TypicalPath     string  `json:"typicalPath"`     // 路径
	ExpireType      int     `json:"expiredType"`     // 过期类型
	ExpireTime      int64   `json:"expiredTime"`     // 过期时间
	ViewCount       int     `json:"vCnt"`            // 浏览次数
	Valid           string  // 是否过期
}

ShareRecordInfo 分享信息

type ShareRecordInfoList

type ShareRecordInfoList []*ShareRecordInfo

ShareRecordInfoList 分享信息列表

type ShareSURLInfo

type ShareSURLInfo struct {
	Pwd      string `json:"pwd"` // 新密码
	ShortURL string `json:"shorturl"`
}

ShareSURLInfo 分享的子信息

type Shared

type Shared struct {
	Link    string `json:"link"`
	Pwd     string `json:"pwd"`
	ShareID int64  `json:"shareid"`
}

Shared 分享信息

type TransferOption

type TransferOption struct {
	Download bool // 是否直接开始下载
	Collect  bool // 多文件整合
	Rname    bool // 随机改文件名
}

ShareOption 分享可选项

type URLInfo

type URLInfo struct {
	URLs []struct {
		URL string `json:"url"`
	} `json:"urls"`
}

URLInfo 下载链接详情

func (*URLInfo) LastURL

func (ui *URLInfo) LastURL(https bool) *url.URL

LastURL 返回最后一条下载链接

func (*URLInfo) SingleURL

func (ui *URLInfo) SingleURL(https bool) *url.URL

SingleURL 返回单条下载链接

func (*URLInfo) URLStrings

func (ui *URLInfo) URLStrings(https bool) (urls []*url.URL)

URLStrings 返回下载链接数组

type UploadFunc

type UploadFunc func(uploadURL string, jar http.CookieJar) (resp *http.Response, err error)

UploadFunc 上传文件处理函数

type UploadSeq

type UploadSeq struct {
	Seq   int
	Block string
}

UploadSeq 分片上传顺序

Directories

Path Synopsis
internal
Package pcserror PCS错误包
Package pcserror PCS错误包

Jump to

Keyboard shortcuts

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