Documentation
¶
Index ¶
- Constants
- Variables
- func BoolToInt(b bool) int
- func CheckErr(err error, result ResultWithErr, restyResp *resty.Response) error
- func Date() string
- func GetErr(code int, respBody ...string) error
- func OssOption(params *UploadOSSParams, ossToken *UploadOSSTokenResp) []oss.Option
- func SplitFile(filePath string, fileSize int64) (chunks []oss.FileChunk, err error)
- type APIGetDirIDResp
- type AppVersion
- type BasicBehaviorDetailResp
- type BasicResp
- type BehaviorDetail
- type BehaviorDetailItem
- type BehaviorDetailResp
- type BoolInt
- type Credential
- type DataString
- type Device
- type DirInfo
- type DownloadData
- type DownloadInfo
- type DownloadResp
- type File
- type FileDownloadUrl
- type FileInfo
- type FileListResp
- type FileParentInfo
- type FileStatInfo
- type FileStatResponse
- type GetFileInfoResponse
- type GetFileOption
- type GetFileOptions
- type InfoData
- type InfoResponse
- type IntString
- type Label
- type LabelColor
- type LabelInfo
- type LastDevice
- type ListOption
- type ListOptions
- type LoginApp
- type LoginDevicesInfo
- type LoginResp
- type MkdirResp
- type OfflineAddUrlResponse
- type OfflineOption
- type OfflineOptions
- type OfflineTask
- type OfflineTaskResp
- type OfflineTaskResponse
- type Option
- type Pan115Client
- func (c *Pan115Client) AddOfflineTaskURIs(uris []string, saveDirID string, opts ...OfflineOption) (hashes []string, err error)
- func (c *Pan115Client) BehaviorDetail(payload interface{}) (*BehaviorDetailResp, error)
- func (c *Pan115Client) BehaviorDetailWithApp(app string, payload interface{}) (*BehaviorDetailResp, error)
- func (c *Pan115Client) CleanRecycleBin(password string, rIDs ...string) error
- func (c *Pan115Client) ClearOfflineTasks(clearFlag int64) error
- func (c *Pan115Client) CookieCheck() error
- func (c *Pan115Client) Copy(dirID string, fileIDs ...string) error
- func (c *Pan115Client) Delete(fileIDs ...string) error
- func (c *Pan115Client) DeleteOfflineTasks(hashes []string, deleteFiles bool) error
- func (c *Pan115Client) DirName2CID(dir string) (*APIGetDirIDResp, error)
- func (c *Pan115Client) Download(pickCode string) (*DownloadInfo, error)
- func (c *Pan115Client) DownloadByShareCode(shareCode, receiveCode, fileID string) (*SharedDownloadInfo, error)
- func (c *Pan115Client) DownloadWithUA(pickCode, ua string) (*DownloadInfo, error)
- func (c *Pan115Client) DownloadWithUAByAndroidAPI(pickCode string, ua string) (*DownloadInfo, error)
- func (c *Pan115Client) EnableTrace() *Pan115Client
- func (c *Pan115Client) GenerateSignature(fileID, target string) string
- func (c *Pan115Client) GenerateToken(fileID, preID, timeStamp, fileSize, signKey, signVal string) string
- func (c *Pan115Client) GetAppVersion() ([]AppVersion, error)
- func (c *Pan115Client) GetDigestResult(r io.Reader) (*hash.DigestResult, error)
- func (c *Pan115Client) GetFile(fileID string) (*File, error)
- func (c *Pan115Client) GetInfo() (InfoData, error)
- func (c *Pan115Client) GetOSSEndpoint(enableInternalUpload bool) string
- func (c *Pan115Client) GetOSSToken() (*UploadOSSTokenResp, error)
- func (c *Pan115Client) GetRequest() *resty.Request
- func (c *Pan115Client) GetShareSnap(shareCode, receiveCode, dirID string, Queries ...Query) (*ShareSnapResp, error)
- func (c *Pan115Client) GetUploadEndpoint(endpoint *UploadEndpointResp) error
- func (c *Pan115Client) GetUploadInfo() error
- func (c *Pan115Client) GetUser() (*UserInfo, error)
- func (c *Pan115Client) ImportCookies(cookies map[string]string, domains ...string)
- func (c *Pan115Client) ImportCredential(cr *Credential) *Pan115Client
- func (c *Pan115Client) List(dirID string, opts ...ListOption) (*[]File, error)
- func (c *Pan115Client) ListOfflineTask(page int64) (OfflineTaskResp, error)
- func (c *Pan115Client) ListPage(dirID string, offset, limit int64, opts ...ListOption) (*[]File, *[]PathInfo, error)
- func (c *Pan115Client) ListRecycleBin(offset, limit int) ([]RecycleBinItem, error)
- func (c *Pan115Client) ListWithLimit(dirID string, limit int64, opts ...ListOption) (*[]File, error)
- func (c *Pan115Client) LoginCheck() error
- func (c *Pan115Client) Mkdir(parentID string, name string) (string, error)
- func (c *Pan115Client) Move(dirID string, fileIDs ...string) error
- func (c *Pan115Client) NewRequest() *resty.Request
- func (c *Pan115Client) QRCodeLogin(s *QRCodeSession) (*Credential, error)
- func (c *Pan115Client) QRCodeLoginWithApp(s *QRCodeSession, app LoginApp) (*Credential, error)
- func (c *Pan115Client) QRCodeStart() (*QRCodeSession, error)
- func (c *Pan115Client) QRCodeStatus(s *QRCodeSession) (*QRCodeStatus, error)
- func (c *Pan115Client) RapidUpload(fileSize int64, fileName, dirID, preID, fileID string, r io.ReadSeeker) (*UploadInitResp, error)
- func (c *Pan115Client) RapidUploadOrByMultipart(dirID, fileName string, fileSize int64, r *os.File, ...) error
- func (c *Pan115Client) RapidUploadOrByOSS(dirID, fileName string, fileSize int64, r io.ReadSeeker) error
- func (c *Pan115Client) Rename(fileID, newName string) error
- func (c *Pan115Client) RevertRecycleBin(rIDs ...string) error
- func (c *Pan115Client) Search(opts *SearchOption) (*SearchResult, error)
- func (c *Pan115Client) SetCookies(cs ...*http.Cookie) *Pan115Client
- func (c *Pan115Client) SetDebug(d bool) *Pan115Client
- func (c *Pan115Client) SetHttpClient(httpClient *http.Client) *Pan115Client
- func (c *Pan115Client) SetProxy(proxy string) *Pan115Client
- func (c *Pan115Client) SetUserAgent(userAgent string) *Pan115Client
- func (c *Pan115Client) Stat(fileID string) (*FileStatInfo, error)
- func (c *Pan115Client) UploadAvailable() (bool, error)
- func (c *Pan115Client) UploadByMultipart(params *UploadOSSParams, fileSize int64, f *os.File, dirID string, ...) error
- func (c *Pan115Client) UploadByOSS(params *UploadOSSParams, r io.Reader, dirID string) error
- func (c *Pan115Client) UploadDigestRange(r io.ReadSeeker, rangeSpec string) (result string, err error)
- func (c *Pan115Client) UploadFastOrByMultipart(dirID, fileName string, fileSize int64, r *os.File, ...) error
- func (c *Pan115Client) UploadFastOrByOSS(dirID, fileName string, fileSize int64, r io.ReadSeeker) error
- func (c *Pan115Client) UploadSHA1(fileSize int64, fileName, dirID, preID, fileID string, r io.ReadSeeker) (*UploadInitResp, error)
- type PathInfo
- type Privilege
- type QRCodeBasicResp
- type QRCodeLoginResp
- type QRCodeSession
- type QRCodeStatus
- type QRCodeStatusResp
- type QRCodeTokenResp
- type Query
- type RecycleBinItem
- type RecycleListResponse
- type RemainSize
- type ResultWithErr
- type SearchFile
- type SearchOption
- type SearchResult
- type ShareFile
- type ShareSnapResp
- type SharedDownloadInfo
- type SpaceInfo
- type StringFloat64
- type StringInt
- type StringInt64
- type StringTime
- type Time
- type TotalSize
- type UploadEndpointResp
- type UploadInfoResp
- type UploadInitResp
- type UploadMetaInfo
- type UploadMultipartOption
- type UploadMultipartOptions
- type UploadOSSParams
- type UploadOSSTokenResp
- type UploadResult
- type UseSize
- type UserInfo
- type UserInfoResp
- type VersionResp
- type Versions
Examples ¶
Constants ¶
const ( ApiGetVersion = "https://appversion.115.com/1/web/1.0/api/chrome" // login ApiLoginCheck = "https://passportapi.115.com/app/1.0/web/1.0/check/sso" ApiUserInfo = "https://my.115.com/?ct=ajax&ac=nav" ApiStatusCheck = "https://my.115.com/?ct=guide&ac=status" // dir ApiDirAdd = "https://webapi.115.com/files/add" ApiDirName2CID = "https://webapi.115.com/files/getid" // file ApiFileDelete = "https://webapi.115.com/rb/delete" ApiFileMove = "https://webapi.115.com/files/move" ApiFileCopy = "https://webapi.115.com/files/copy" ApiFileRename = "https://webapi.115.com/files/batch_rename" ApiFileIndexInfo = "https://webapi.115.com/files/index_info" ApiFileList = "https://webapi.115.com/files" ApiFileList1 = "http://web.api.115.com/files" // ApiFileList2 = "http://anxia.com/webapi/files" // ApiFileList3 = "http://v.anxia.com/webapi/files" ApiFileListByName = "https://aps.115.com/natsort/files.php" ApiFileStat = "https://webapi.115.com/category/get" ApiFileInfo = "https://webapi.115.com/files/get_info" ApiFileSearch = "https://webapi.115.com/files/search" ApiShareSnap = "https://webapi.115.com/share/snap" // download ApiDownloadGetUrl = "https://proapi.115.com/app/chrome/downurl" AndroidApiDownloadGetUrl = "https://proapi.115.com/android/2.0/ufile/download" // offline download ApiAddOfflineUrl = "https://lixian.115.com/lixianssp/?ac=add_task_urls" ApiDelOfflineUrl = "https://lixian.115.com/lixian/?ct=lixian&ac=task_del" ApiListOfflineUrl = "https://lixian.115.com/lixian/?ct=lixian&ac=task_lists" ApiClearOfflineUrl = "https://lixian.115.com/lixian/?ct=lixian&ac=task_clear" // upload ApiUploadInfo = "https://proapi.115.com/app/uploadinfo" ApiGetUploadEndpoint = "https://uplb.115.com/3.0/getuploadinfo.php" ApiUploadInit = "https://uplb.115.com/4.0/initupload.php" // oss ApiUploadOSSToken = "https://uplb.115.com/3.0/gettoken.php" // qrcode ApiQrcodeToken = "https://qrcodeapi.115.com/api/1.0/web/1.0/token" ApiQrcodeStatus = "https://qrcodeapi.115.com/get/status/" ApiQrcodeLogin = "https://passportapi.115.com/app/1.0/web/1.0/login/qrcode" ApiQrcodeLoginWithApp = "https://passportapi.115.com/app/1.0/%s/1.0/login/qrcode" ApiQrcodeImage = "https://qrcodeapi.115.com/api/1.0/mac/1.0/qrcode?uid=%s" // recycle ApiRecycleList = "https://webapi.115.com/rb" ApiRecycleClean = "https://webapi.115.com/rb/clean" ApiRecycleRevert = "https://webapi.115.com/rb/revert" // life ApiBehaviorDetail = "https://proapi.115.com/{app}/1.0/behavior/detail" )
const ( UADefault = "Mozilla/5.0" UADefalut = "Mozilla/5.0" // typo of UADefault, for backward compatibility UA115Browser = "Mozilla/5.0 115Browser/27.0.5.7" UA115Disk = "Mozilla/5.0 115disk/30.1.0" UA115Desktop = "Mozilla/5.0 115Desktop/2.0.3.6" UAIosApp = "Mozilla/5.0; Darwin/10.0; UDown/30.1.0" )
const ( CookieDomain115 = ".115.com" CookieUrl = "https://115.com" CookieNameUid = "UID" CookieNameCid = "CID" CookieNameSeid = "SEID" CookieNameKid = "KID" )
const ( OSSRegionID = "oss-cn-shenzhen" OSSEndpoint = "cn-shenzhen.oss.aliyuncs.com" // 双栈域名 OSSUserAgent = "aliyun-sdk-android/2.9.1" OssSecurityTokenHeaderName = "X-OSS-Security-Token" )
const ( KB = 1 << (10 * (iota + 1)) MB GB )
const ( FileOrderByTime = "user_ptime" FileOrderByType = "file_type" FileOrderBySize = "file_size" FileOrderByName = "file_name" FileListLimit = int64(56) )
const MaxDirPageLimit = 1150
Variables ¶
var ( ErrNotLogin = errors.New("user not login") ErrOfflineNoTimes = errors.New("offline download quota has been used up, you can purchase a VIP experience or upgrade to VIP service to get more quota") ErrOfflineInvalidLink = errors.New("invalid download link") ErrOfflineTaskExisted = errors.New("offline task existed") ErrOrderNotSupport = errors.New("file order not supported") ErrPasswordIncorrect = errors.New("password incorrect") ErrLoginTwoStepVerify = errors.New("requires two-step verification") ErrAccountNotBindMobile = errors.New("account not binds mobile") ErrCredentialInvalid = errors.New("credential invalid") ErrSessionExited = errors.New("session exited") ErrQrcodeExpired = errors.New("qrcode expired") // ErrUnexpected is the fall-back error whose code is not handled. ErrUnexpected = errors.New("unexpected error") // ErrExist means an item which you want to create is already existed. ErrExist = errors.New("target already exists") // ErrNotExist means an item which you find is not existed. ErrNotExist = errors.New("target does not exist") ErrInvalidCursor = errors.New("invalid cursor") ErrUploadTooLarge = errors.New("upload reach the limit") ErrUploadFailed = errors.New("upload failed") ErrImportDirectory = errors.New("can not import directory") ErrDownloadEmpty = errors.New("can not get download URL") ErrDownloadFileNotExistOrHasDeleted = errors.New("target file does not exist or has deleted") ErrDownloadFileTooBig = errors.New("target file is too big to download") ErrCyclicCopy = errors.New("cyclic copy") ErrCyclicMove = errors.New("cyclic move") ErrVideoNotReady = errors.New("video is not ready") ErrWrongParams = errors.New("wrong parameters") ErrRepeatLogin = errors.New("repeat login") ErrFailedToLogin = errors.New("failed to login") ErrDoesLoggedOut = errors.New("you have been kicked out by multi-device login management") ErrPickCodeNotExist = errors.New("pickcode does not exist") ErrPickCodeIsEmpty = errors.New("empty pickcode") ErrUploadSH1Invalid = errors.New("userid/filesize/target/pickcode/ invalid") ErrUploadSigInvalid = errors.New("sig invalid") )
var ( LabelColors = []string{ "#000000", "#FF4B30", "#F78C26", "#FFC032", "#43BA80", "#2670FC", "#8B69FE", "#CCCCCC", } LabelColorMap = map[string]int{ "#000000": 0, "#FF4B30": 1, "#F78C26": 2, "#FFC032": 3, "#43BA80": 4, "#2670FC": 5, "#8B69FE": 6, "#CCCCCC": 7, } )
var (
ErrBadCookie = errors.New("bad cookie")
)
cookie err
var (
ErrorNotSupportAlist = errors.New("not support alist due to privacy risk, please use openlist: https://github.com/OpenListTeam/OpenList")
)
Functions ¶
func OssOption ¶
func OssOption(params *UploadOSSParams, ossToken *UploadOSSTokenResp) []oss.Option
OssOption get options
Types ¶
type APIGetDirIDResp ¶
type AppVersion ¶
type BasicBehaviorDetailResp ¶
type BasicResp ¶
type BehaviorDetail ¶
type BehaviorDetail struct {
Count StringInt64 `json:"count"`
NextPage bool `json:"next_page"`
List []BehaviorDetailItem `json:"list"`
}
BehaviorDetail 行为详情
type BehaviorDetailItem ¶
type BehaviorDetailItem struct {
ID string `json:"id"`
Type int `json:"type"`
FileID string `json:"file_id"`
ParentID string `json:"parent_id"`
FileName string `json:"file_name"`
PickCode string `json:"pick_code"`
FileCategory int `json:"file_category"` //1:文件 0:目录
OldFileName string `json:"old_file_name,omitempty"`
ParentName string `json:"parent_name,omitempty"`
UpdateTime int64 `json:"update_time"`
CreateTime int64 `json:"create_time"`
}
BehaviorDetailItem 行为详情项
type BehaviorDetailResp ¶
type BehaviorDetailResp struct {
BasicResp
Data BehaviorDetail `json:"data"`
}
BehaviorDetailResp 行为详情响应
type Credential ¶
type Credential struct {
UID string `json:"UID"`
CID string `json:"CID"`
SEID string `json:"SEID"`
KID string `json:"KID"`
}
func (*Credential) FromCookie ¶
func (cr *Credential) FromCookie(cookie string) error
FromCookie get uid, cid, seid from cookie string
type DataString ¶
type DataString string
func (*DataString) UnmarshalJSON ¶
func (v *DataString) UnmarshalJSON(b []byte) (err error)
type Device ¶
type Device struct {
IsCurrent int `json:"is_current"`
Ssoent string `json:"ssoent"`
Utime int `json:"utime"`
Device string `json:"device"`
Name string `json:"name"`
Icon string `json:"icon"`
Desc string `json:"desc"`
IP string `json:"ip"`
City string `json:"city"`
IsUnusual int `json:"is_unusual"`
}
type DownloadData ¶
type DownloadData map[string]*DownloadInfo
type DownloadInfo ¶
type DownloadInfo struct {
FileName string `json:"file_name"`
FileSize StringInt64 `json:"file_size"`
PickCode string `json:"pick_code"`
Url FileDownloadUrl `json:"url"`
Header http.Header
}
func (*DownloadInfo) Get ¶
func (info *DownloadInfo) Get() (io.ReadSeeker, error)
Get Download file from download info url
type DownloadResp ¶
type DownloadResp struct {
BasicResp
EncodedData DataString `json:"data,omitempty"`
}
type File ¶
type File struct {
// Marks is the file a directory.
IsDirectory bool
// Unique identifier of the file on the cloud storage.
FileID string
// FileID of the parent directory.
ParentID string
// Base name of the file.
Name string
// Size in bytes of the file.
Size int64
// IDentifier used for downloading or playing the file.
PickCode string
// SHA1 hash of file content, in HEX format.
Sha1 string
// Is file stared
Star bool
// File labels
Labels []*Label
// Create time of the file.
CreateTime time.Time
// Update time of the file.
UpdateTime time.Time
}
type FileDownloadUrl ¶
type FileInfo ¶
type FileInfo struct {
AreaID IntString `json:"aid"`
CategoryID IntString `json:"cid"`
FileID string `json:"fid"`
ParentID string `json:"pid"`
Name string `json:"n"`
Type string `json:"ico"`
Size StringInt64 `json:"s"`
Sha1 string `json:"sha"`
PickCode string `json:"pc"`
IsStar StringInt `json:"m"`
Labels []*LabelInfo `json:"fl"`
CreateTime StringInt64 `json:"tp"`
UpdateTime string `json:"t"`
}
type FileListResp ¶
type FileListResp struct {
BasicResp
AreaID string `json:"aid"`
CategoryID IntString `json:"cid"`
Count int `json:"count"`
Order string `json:"order"`
IsAsc int `json:"is_asc"`
Offset int `json:"offset"`
Limit int `json:"limit"`
PageSize int `json:"page_size"`
Files []FileInfo `json:"data"`
Paths []PathInfo `json:"path"`
}
func GetFiles ¶
func GetFiles(req *resty.Request, dirID string, opts ...GetFileOptions) (*FileListResp, error)
type FileParentInfo ¶
type FileStatInfo ¶
type FileStatInfo struct {
// Base name of the file.
Name string
// Identifier used for downloading or playing the file.
PickCode string
// SHA1 hash of file content, in HEX format.
Sha1 string
// Marks is file a directory.
IsDirectory bool
// Files count under this directory.
FileCount int
// Subdirectories count under this directory.
DirCount int
// Create time of the file.
CreateTime time.Time
// Last update time of the file.
UpdateTime time.Time
// Parent directory list.
Parents []*DirInfo
}
type FileStatResponse ¶
type FileStatResponse struct {
FileCount StringInt `json:"count"`
Size string `json:"size"`
FolderCount StringInt `json:"folder_count"`
CreateTime StringInt64 `json:"ptime"`
UpdateTime StringInt64 `json:"utime"`
FileName string `json:"file_name"`
PickCode string `json:"pick_code"`
Sha1 string `json:"sha1"`
IsMark StringInt `json:"is_mark"`
OpenTime int64 `json:"open_time"`
IsFile StringInt `json:"file_category"`
Paths []*FileParentInfo `json:"paths"`
}
func (*FileStatResponse) Err ¶
func (r *FileStatResponse) Err(respBody ...string) error
type GetFileInfoResponse ¶
type GetFileOption ¶
type GetFileOption struct {
// contains filtered or unexported fields
}
GetFileOption get file options
func DefaultGetFileOptions ¶
func DefaultGetFileOptions() *GetFileOption
func (*GetFileOption) GetApiURL ¶
func (o *GetFileOption) GetApiURL() string
func (*GetFileOption) GetAsc ¶
func (o *GetFileOption) GetAsc() string
func (*GetFileOption) GetOffset ¶
func (o *GetFileOption) GetOffset() string
func (*GetFileOption) GetOrder ¶
func (o *GetFileOption) GetOrder() string
func (*GetFileOption) GetPageSize ¶
func (o *GetFileOption) GetPageSize() string
func (*GetFileOption) GetshowDir ¶
func (o *GetFileOption) GetshowDir() string
type GetFileOptions ¶
type GetFileOptions func(o *GetFileOption)
func WithApiURL ¶
func WithApiURL(url string) GetFileOptions
func WithAsc ¶
func WithAsc(d bool) GetFileOptions
func WithLimit ¶
func WithLimit(pageSize int64) GetFileOptions
func WithOffset ¶
func WithOffset(offset int64) GetFileOptions
func WithOrder ¶
func WithOrder(order string) GetFileOptions
func WithShowDirEnable ¶
func WithShowDirEnable(e bool) GetFileOptions
type InfoData ¶
type InfoData struct {
SpaceInfo SpaceInfo `json:"space_info"`
LoginDevicesInfo LoginDevicesInfo `json:"login_devices_info"`
ImeiInfo bool `json:"imei_info"`
}
type InfoResponse ¶
type Label ¶
type Label struct {
ID string
Name string
Color LabelColor
}
type LabelColor ¶
type LabelColor int
type LastDevice ¶
type ListOption ¶
type ListOption func(o *ListOptions)
func WithApiURLs ¶
func WithApiURLs(urls ...string) ListOption
func WithMultiUrls ¶
func WithMultiUrls() ListOption
type ListOptions ¶
type ListOptions struct {
ApiURLs []string
}
func DefaultListOptions ¶
func DefaultListOptions() *ListOptions
type LoginApp ¶
type LoginApp string
const ( LoginAppWeb LoginApp = "web" LoginAppAndroid LoginApp = "android" LoginAppIOS LoginApp = "ios" // LoginAppLinux LoginApp = "linux" // disabled // LoginAppMac LoginApp = "mac" // disabled // LoginAppWindows LoginApp = "windows" // disabled LoginAppTV LoginApp = "tv" LoginAppAlipayMini LoginApp = "alipaymini" LoginAppWechatMini LoginApp = "wechatmini" LoginQAppAndroid LoginApp = "qandroid" )
type LoginDevicesInfo ¶
type LoginDevicesInfo struct {
Last LastDevice `json:"last"`
List []Device `json:"list"`
}
type LoginResp ¶
type LoginResp struct {
Code int `json:"code"`
CheckSsd bool `json:"check_ssd"`
Data struct {
Expire int64 `json:"expire"`
Link string `json:"link"`
UserID int64 `json:"user_id"`
} `json:"data"`
Errno int `json:"errno"`
Error string `json:"error"`
Message string `json:"message"`
State int `json:"state"`
Expire int `json:"expire"`
}
type OfflineAddUrlResponse ¶
type OfflineAddUrlResponse struct {
BasicResp
Result []OfflineTaskResponse `json:"result"`
}
type OfflineOption ¶
type OfflineOption func(o *OfflineOptions)
func WithAppVer ¶
func WithAppVer(appVer string) OfflineOption
type OfflineOptions ¶
type OfflineOptions struct {
// contains filtered or unexported fields
}
func DefaultOfflineOptions ¶
func DefaultOfflineOptions() OfflineOptions
type OfflineTask ¶
type OfflineTask struct {
InfoHash string `json:"info_hash"`
Name string `json:"name"`
Size int64 `json:"size"`
Url string `json:"url"`
AddTime int64 `json:"add_time"`
Peers int64 `json:"peers"`
RateDownload float64 `json:"rateDownload"`
Status int `json:"status"`
Percent float64 `json:"percentDone"`
UpdateTime int64 `json:"last_update"`
LeftTime int64 `json:"left_time"`
FileId string `json:"file_id"`
DelFileId string `json:"delete_file_id"`
DirId string `json:"wp_path_id"`
Move int `json:"move"`
}
OfflineTask describe an offline downloading task.
func (*OfflineTask) GetStatus ¶
func (t *OfflineTask) GetStatus() string
func (*OfflineTask) IsDone ¶
func (t *OfflineTask) IsDone() bool
func (*OfflineTask) IsFailed ¶
func (t *OfflineTask) IsFailed() bool
func (*OfflineTask) IsRunning ¶
func (t *OfflineTask) IsRunning() bool
func (*OfflineTask) IsTodo ¶
func (t *OfflineTask) IsTodo() bool
type OfflineTaskResp ¶
type OfflineTaskResponse ¶
type Option ¶
type Option func(c *Pan115Client)
Option driver client options
func InsecureSkipVerify ¶
func WithClient ¶
func WithRestyClient ¶
type Pan115Client ¶
type Pan115Client struct {
Client *resty.Client
Request *resty.Request
UserID int64
Userkey string
UploadMetaInfo *UploadMetaInfo
UseInternalUpload bool
}
Pan115Client driver client
func (*Pan115Client) AddOfflineTaskURIs ¶
func (c *Pan115Client) AddOfflineTaskURIs(uris []string, saveDirID string, opts ...OfflineOption) (hashes []string, err error)
AddOfflineTaskURIs adds offline tasks by download URIs. supports http, ed2k, magent
func (*Pan115Client) BehaviorDetail ¶
func (c *Pan115Client) BehaviorDetail(payload interface{}) (*BehaviorDetailResp, error)
BehaviorDetail 获取行为详情 参数说明:
- type: 操作类型,可以是以下值之一:
- "browser_image": 浏览图片
- "browser_video": 浏览视频
- "browser_document": 浏览文件
- "new_folder": 新增目录
- "copy_folder": 复制目录
- "folder_rename": 目录改名
- "folder_label": 目录设置标签
- "star_file": 设置星标
- "move_file": 移动文件或目录
- "delete_file": 删除文件或目录
- "upload_file": 上传文件
- "upload_image_file": 上传图片
- "receive_files": 接收文件
- "rename_file": 文件改名(未实现)
- "copy_file": 复制文件(未实现)
- limit: 返回数量,默认32
- offset: 偏移量,默认0
- date: 日期,格式为yyyy-mm-dd,默认为今天
func (*Pan115Client) BehaviorDetailWithApp ¶
func (c *Pan115Client) BehaviorDetailWithApp(app string, payload interface{}) (*BehaviorDetailResp, error)
BehaviorDetailWithApp 获取行为详情(指定app)
func (*Pan115Client) CleanRecycleBin ¶
func (c *Pan115Client) CleanRecycleBin(password string, rIDs ...string) error
CleanRecycleBin clean the recycle bin
func (*Pan115Client) ClearOfflineTasks ¶
func (c *Pan115Client) ClearOfflineTasks(clearFlag int64) error
ClearOfflineTasks deletes tasks.
func (*Pan115Client) CookieCheck ¶
func (c *Pan115Client) CookieCheck() error
CookieCheck checks the cookie status and will not logout of other devices.
func (*Pan115Client) Copy ¶
func (c *Pan115Client) Copy(dirID string, fileIDs ...string) error
Copy copy files or directory into another directory with directroy id
Example ¶
client := Default()
err := client.Copy("dirID", "fileID")
if err != nil {
log.Fatalf("Copy file error: %s", err)
}
func (*Pan115Client) Delete ¶
func (c *Pan115Client) Delete(fileIDs ...string) error
Delete delete files or directory from file ids
Example ¶
client := Default()
err := client.Delete("fileID")
if err != nil {
log.Fatalf("Delete file error: %s", err)
}
func (*Pan115Client) DeleteOfflineTasks ¶
func (c *Pan115Client) DeleteOfflineTasks(hashes []string, deleteFiles bool) error
DeleteOfflineTasks deletes tasks.
func (*Pan115Client) DirName2CID ¶
func (c *Pan115Client) DirName2CID(dir string) (*APIGetDirIDResp, error)
func (*Pan115Client) Download ¶
func (c *Pan115Client) Download(pickCode string) (*DownloadInfo, error)
Download get download info with pickcode
Example ¶
client := Default()
info, err := client.Download("pickcode")
if err != nil {
log.Fatalf("Get download info error: %s", err)
}
rs, err := info.Get()
if err != nil {
log.Fatalf("Get io reader error: %s", err)
}
f, _ := os.Create("test.mp4") // save to test.mp4
defer func() {
f.Close()
}()
_, err = f.ReadFrom(rs)
if err != nil {
log.Fatalf("Copy reader error: %s", err)
}
func (*Pan115Client) DownloadByShareCode ¶
func (c *Pan115Client) DownloadByShareCode(shareCode, receiveCode, fileID string) (*SharedDownloadInfo, error)
DownloadByShareCode get download info with share code
func (*Pan115Client) DownloadWithUA ¶
func (c *Pan115Client) DownloadWithUA(pickCode, ua string) (*DownloadInfo, error)
DownloadWithUA get download info with pickcode and user agent
func (*Pan115Client) DownloadWithUAByAndroidAPI ¶
func (c *Pan115Client) DownloadWithUAByAndroidAPI(pickCode string, ua string) (*DownloadInfo, error)
DownloadWithUAByAndroidAPI get download info with pickcode and user agent
func (*Pan115Client) EnableTrace ¶
func (c *Pan115Client) EnableTrace() *Pan115Client
func (*Pan115Client) GenerateSignature ¶
func (c *Pan115Client) GenerateSignature(fileID, target string) string
func (*Pan115Client) GenerateToken ¶
func (c *Pan115Client) GenerateToken(fileID, preID, timeStamp, fileSize, signKey, signVal string) string
func (*Pan115Client) GetAppVersion ¶
func (c *Pan115Client) GetAppVersion() ([]AppVersion, error)
GetAppVersion get app version (win, android, mac, mac_arc, etc...)
func (*Pan115Client) GetDigestResult ¶
func (c *Pan115Client) GetDigestResult(r io.Reader) (*hash.DigestResult, error)
GetDigestResult get digest of file or stream
func (*Pan115Client) GetFile ¶
func (c *Pan115Client) GetFile(fileID string) (*File, error)
GetFile gets information of a file or directory by its ID.
func (*Pan115Client) GetInfo ¶
func (c *Pan115Client) GetInfo() (InfoData, error)
GetInfo get space info and login device info.
func (*Pan115Client) GetOSSEndpoint ¶
func (c *Pan115Client) GetOSSEndpoint(enableInternalUpload bool) string
GetOSSEndpoint get oss endpoint 利用阿里云内网上传文件,需要在阿里云服务器上运行本程序,同时也需要115在服务器的所在地域开通了阿里云OSS
func (*Pan115Client) GetOSSToken ¶
func (c *Pan115Client) GetOSSToken() (*UploadOSSTokenResp, error)
GetOSSToken get oss token for oss upload
func (*Pan115Client) GetRequest ¶
func (c *Pan115Client) GetRequest() *resty.Request
func (*Pan115Client) GetShareSnap ¶
func (c *Pan115Client) GetShareSnap(shareCode, receiveCode, dirID string, Queries ...Query) (*ShareSnapResp, error)
GetShareSnap get share snap info
func (*Pan115Client) GetUploadEndpoint ¶
func (c *Pan115Client) GetUploadEndpoint(endpoint *UploadEndpointResp) error
GetUploadEndpoint get upload endPoint
func (*Pan115Client) GetUploadInfo ¶
func (c *Pan115Client) GetUploadInfo() error
GetUploadInfo get some info for upload
func (*Pan115Client) GetUser ¶
func (c *Pan115Client) GetUser() (*UserInfo, error)
GetUser get user information
func (*Pan115Client) ImportCookies ¶
func (c *Pan115Client) ImportCookies(cookies map[string]string, domains ...string)
func (*Pan115Client) ImportCredential ¶
func (c *Pan115Client) ImportCredential(cr *Credential) *Pan115Client
ImportCredential import uid, cid, seid
Example ¶
cr := &Credential{}
if err := cr.FromCookie("UID=xxx;CID=xxxx;SEID=xxx;KID=xxx;other=xxxx"); err != nil {
log.Fatalf("Import credentail error: %s", err)
}
client := Default().ImportCredential(cr)
if err := client.LoginCheck(); err != nil {
log.Fatalf("Login error: %s", err)
}
func (*Pan115Client) List ¶
func (c *Pan115Client) List(dirID string, opts ...ListOption) (*[]File, error)
List list all files and directories
Example ¶
client := Default()
files, err := client.List("dirID")
if err != nil {
log.Fatalf("List file error: %s", err)
}
for _, file := range *files {
log.Printf("file %v", file)
}
func (*Pan115Client) ListOfflineTask ¶
func (c *Pan115Client) ListOfflineTask(page int64) (OfflineTaskResp, error)
ListOfflineTask list tasks
func (*Pan115Client) ListPage ¶
func (c *Pan115Client) ListPage(dirID string, offset, limit int64, opts ...ListOption) (*[]File, *[]PathInfo, error)
ListPage list files and directories with page
func (*Pan115Client) ListRecycleBin ¶
func (c *Pan115Client) ListRecycleBin(offset, limit int) ([]RecycleBinItem, error)
ListRecycleBin list the recycle bin
func (*Pan115Client) ListWithLimit ¶
func (c *Pan115Client) ListWithLimit(dirID string, limit int64, opts ...ListOption) (*[]File, error)
ListWithLimit list all files and directories with limit
func (*Pan115Client) LoginCheck ¶
func (c *Pan115Client) LoginCheck() error
LoginCheck checks the login status and will logout of other devices.
func (*Pan115Client) Mkdir ¶
func (c *Pan115Client) Mkdir(parentID string, name string) (string, error)
Mkdir make a new directory which name and parent directory id, return directory id
Example ¶
client := Default()
cid, err := client.Mkdir("parentID", "name")
if err != nil {
log.Fatalf("Make directory error: %s", err)
}
log.Printf("cid is %s", cid)
func (*Pan115Client) Move ¶
func (c *Pan115Client) Move(dirID string, fileIDs ...string) error
Move move files or directory into another directory with directroy id
Example ¶
client := Default()
err := client.Move("dirID", "fileID")
if err != nil {
log.Fatalf("Move file error: %s", err)
}
func (*Pan115Client) NewRequest ¶
func (c *Pan115Client) NewRequest() *resty.Request
func (*Pan115Client) QRCodeLogin ¶
func (c *Pan115Client) QRCodeLogin(s *QRCodeSession) (*Credential, error)
QRCodeLogin logins user through QRCode with web app. You SHOULD call this method ONLY when `QRCodeStatus.IsAllowed()` is true.
func (*Pan115Client) QRCodeLoginWithApp ¶
func (c *Pan115Client) QRCodeLoginWithApp(s *QRCodeSession, app LoginApp) (*Credential, error)
QRCodeLoginWithApp logins user through QRCode with specified app. You SHOULD call this method ONLY when `QRCodeStatus.IsAllowed()` is true.
func (*Pan115Client) QRCodeStart ¶
func (c *Pan115Client) QRCodeStart() (*QRCodeSession, error)
QRCodeStart starts a QRCode login session.
func (*Pan115Client) QRCodeStatus ¶
func (c *Pan115Client) QRCodeStatus(s *QRCodeSession) (*QRCodeStatus, error)
QRCodeStatus represents the status of a QRCode session.
There are 4 possible status values: - Waiting - Scanned - Allowed - Canceled
func (*Pan115Client) RapidUpload ¶
func (c *Pan115Client) RapidUpload(fileSize int64, fileName, dirID, preID, fileID string, r io.ReadSeeker) (*UploadInitResp, error)
RapidUpload rapid upload
func (*Pan115Client) RapidUploadOrByMultipart ¶
func (c *Pan115Client) RapidUploadOrByMultipart(dirID, fileName string, fileSize int64, r *os.File, opts ...UploadMultipartOption) error
RapidUploadOrByMultipart upload by mutipart blocks when unable to rapid upload
func (*Pan115Client) RapidUploadOrByOSS ¶
func (c *Pan115Client) RapidUploadOrByOSS(dirID, fileName string, fileSize int64, r io.ReadSeeker) error
RapidUploadOrByOSS Upload By OSS when unable to rapid upload file
func (*Pan115Client) Rename ¶
func (c *Pan115Client) Rename(fileID, newName string) error
Rename rename a file or directory with file id and name
Example ¶
client := Default()
err := client.Rename("fileID", "newname")
if err != nil {
log.Fatalf("Rename file error: %s", err)
}
func (*Pan115Client) RevertRecycleBin ¶
func (c *Pan115Client) RevertRecycleBin(rIDs ...string) error
RevertRecycleBin revert the recycle bin
func (*Pan115Client) Search ¶
func (c *Pan115Client) Search(opts *SearchOption) (*SearchResult, error)
Search searches for files using given options
Example ¶
client := Default()
opts := &SearchOption{
SearchValue: "2025",
Offset: 0,
Limit: 30,
Type: 0, // All types
Asc: 1, // Ascending order
Order: "file_name", // Sort by filename
}
result, err := client.Search(opts)
if err != nil {
log.Fatalf("Search error: %s", err)
}
log.Printf("Found %d files\n", result.Count)
for _, file := range result.Files {
if file.IsDirectory {
log.Printf("Directory: %s", file.Name)
} else {
log.Printf("File: %s (%d bytes)", file.Name, file.Size)
}
}
func (*Pan115Client) SetCookies ¶
func (c *Pan115Client) SetCookies(cs ...*http.Cookie) *Pan115Client
func (*Pan115Client) SetDebug ¶
func (c *Pan115Client) SetDebug(d bool) *Pan115Client
func (*Pan115Client) SetHttpClient ¶
func (c *Pan115Client) SetHttpClient(httpClient *http.Client) *Pan115Client
func (*Pan115Client) SetProxy ¶
func (c *Pan115Client) SetProxy(proxy string) *Pan115Client
func (*Pan115Client) SetUserAgent ¶
func (c *Pan115Client) SetUserAgent(userAgent string) *Pan115Client
func (*Pan115Client) Stat ¶
func (c *Pan115Client) Stat(fileID string) (*FileStatInfo, error)
Stat get statistic information of a file or directory
func (*Pan115Client) UploadAvailable ¶
func (c *Pan115Client) UploadAvailable() (bool, error)
UploadAvailable check and prepare to upload
func (*Pan115Client) UploadByMultipart ¶
func (c *Pan115Client) UploadByMultipart(params *UploadOSSParams, fileSize int64, f *os.File, dirID string, opts ...UploadMultipartOption) error
UploadByMultipart upload by mutipart blocks
func (*Pan115Client) UploadByOSS ¶
func (c *Pan115Client) UploadByOSS(params *UploadOSSParams, r io.Reader, dirID string) error
UploadByOSS use aliyun sdk to upload
func (*Pan115Client) UploadDigestRange ¶
func (c *Pan115Client) UploadDigestRange(r io.ReadSeeker, rangeSpec string) (result string, err error)
func (*Pan115Client) UploadFastOrByMultipart ¶
func (c *Pan115Client) UploadFastOrByMultipart(dirID, fileName string, fileSize int64, r *os.File, opts ...UploadMultipartOption) error
UploadFastOrByMultipart upload by mutipart blocks when unable to rapid upload Deprecated: As of v1.0.22, this function simply calls [RapidUploadOrByMultipart].
func (*Pan115Client) UploadFastOrByOSS ¶
func (c *Pan115Client) UploadFastOrByOSS(dirID, fileName string, fileSize int64, r io.ReadSeeker) error
UploadFastOrByOSS Upload By OSS when unable to rapid upload file Deprecated: As of v1.0.22, this function simply calls [RapidUploadOrByOSS].
Example ¶
client := Default()
file, err := os.Open("/path/to/file")
if err != nil {
log.Fatalf("Open file error: %s", err)
}
s, _ := file.Stat()
err = client.UploadFastOrByOSS("dirID", s.Name(), s.Size(), file)
if err != nil {
log.Fatalf("Upload by oss error: %s", err)
}
func (*Pan115Client) UploadSHA1 ¶
func (c *Pan115Client) UploadSHA1(fileSize int64, fileName, dirID, preID, fileID string, r io.ReadSeeker) (*UploadInitResp, error)
UploadSHA1 upload a sha1, alias of RapidUpload Deprecated: As of v1.0.22, this function simply calls [RapidUpload].
Example ¶
client := Default()
file, err := os.Open("/path/to/file")
if err != nil {
log.Fatalf("Open file error: %s", err)
}
d, _ := client.GetDigestResult(file)
resp, err := client.UploadSHA1(d.Size, "filename", "dirID", d.PreID, d.QuickID, file)
if err != nil {
log.Fatalf("Fastupload error: %s", err)
}
success, err := resp.Ok()
if err != nil {
log.Fatalf("Fastupload error: %s", err)
}
if !success {
log.Printf("file is not exist, need upload")
}
type QRCodeBasicResp ¶
type QRCodeBasicResp struct {
Code int `json:"code"`
Message string `json:"message"`
State int `json:"state"`
Errno int `json:"errno"`
Error string `json:"error"`
}
func (*QRCodeBasicResp) Err ¶
func (resp *QRCodeBasicResp) Err(respBody ...string) error
type QRCodeLoginResp ¶
type QRCodeLoginResp struct {
QRCodeBasicResp
Data struct {
Alert string `json:"alert"`
BindMobile int `json:"bind_mobile"`
Credential Credential `json:"cookie"`
Country string `json:"country"`
Email string `json:"email"`
Face struct {
FaceL string `json:"face_l"`
FaceM string `json:"face_m"`
FaceS string `json:"face_s"`
} `json:"face"`
From string `json:"from"`
IsChangPasswd int `json:"is_chang_passwd"`
IsFirstLogin int `json:"is_first_login"`
IsTrusted interface{} `json:"is_trusted"`
IsVip int64 `json:"is_vip"`
Mark int `json:"mark"`
Mobile string `json:"mobile"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
} `json:"data"`
}
type QRCodeSession ¶
type QRCodeSession struct {
// The raw data of QRCode, caller should use third-party tools/libraries
// to convert it into QRCode matrix or image.
QrcodeContent string `json:"qrcode"`
Sign string `json:"sign"`
Time int64 `json:"time"`
UID string `json:"uid"`
}
func (*QRCodeSession) QRCode ¶
func (s *QRCodeSession) QRCode() ([]byte, error)
QRCode get QRCode matrix or image.
func (*QRCodeSession) QRCodeByApi ¶
func (s *QRCodeSession) QRCodeByApi() ([]byte, error)
QRCodeByApi get QRCode matrix or image by api.
type QRCodeStatus ¶
type QRCodeStatus struct {
Msg string `json:"msg"`
Status int `json:"status"`
Version string `json:"version"`
}
func (*QRCodeStatus) IsAllowed ¶
func (s *QRCodeStatus) IsAllowed() bool
func (*QRCodeStatus) IsCanceled ¶
func (s *QRCodeStatus) IsCanceled() bool
func (*QRCodeStatus) IsExpired ¶
func (s *QRCodeStatus) IsExpired() bool
func (*QRCodeStatus) IsScanned ¶
func (s *QRCodeStatus) IsScanned() bool
func (*QRCodeStatus) IsWaiting ¶
func (s *QRCodeStatus) IsWaiting() bool
type QRCodeStatusResp ¶
type QRCodeStatusResp struct {
QRCodeBasicResp
Data QRCodeStatus `json:"data"`
}
type QRCodeTokenResp ¶
type QRCodeTokenResp struct {
QRCodeBasicResp
Data QRCodeSession `json:"data"`
}
type RecycleBinItem ¶
type RecycleBinItem struct {
FileId string `json:"id"`
FileName string `json:"file_name"`
FileSize StringInt64 `json:"file_size"`
ParentId IntString `json:"cid"`
ParentName string `json:"parent_name"`
DeleteTime StringInt64 `json:"dtime"`
}
type RecycleListResponse ¶
type RecycleListResponse struct {
BasicResp
Data []RecycleBinItem `json:"data"`
}
type RemainSize ¶
type ResultWithErr ¶
type SearchFile ¶
type SearchFile struct {
// File ID
FileID string `json:"fid"`
// Category ID
CategoryID IntString `json:"cid"`
// File name
Name string `json:"n"`
// File size
Size StringInt64 `json:"s"`
// SHA1 hash
Sha1 string `json:"sha"`
// PickCode
PickCode string `json:"pc"`
// Is directory
IsDirectory int `json:"fc"`
// Is starred file
IsStar StringInt `json:"m"`
// Update time
UpdateTime string `json:"t"`
// Create time
CreateTime StringInt64 `json:"tp"`
// File type icon
Icon string `json:"ico"`
// Highlighted file name
HighlightName string `json:"ns"`
// File labels
Labels []*LabelInfo `json:"fl"`
// Thumbnail URL
ThumbURL string `json:"u"`
}
SearchFile represents a file in search results
type SearchOption ¶
type SearchOption struct {
// Offset for pagination
Offset int
// Limit number of results
Limit int
// SearchValue search keyword
SearchValue string
// Date filter
Date string
// Aid area ID
Aid string
// Cid category ID
Cid string
// PickCode pickcode
PickCode string
// Type file type filter 0:all 1:folder 2:document 3:image 4:video 5:audio 6:archive
Type int
// CountFolders whether to count folders
CountFolders int
// Source source filter
Source string
// Star star file only
Star string
// Suffix file suffix filter
Suffix string
// Order sort field
Order string
// Asc ascending order 0:descending 1:ascending
Asc int
}
SearchOption defines options for search
type SearchResult ¶
type SearchResult struct {
// File list
Files []File `json:"data"`
// Total count
Count int `json:"count"`
// File count
FileCount int `json:"file_count"`
// Folder count
FolderCount int `json:"folder_count"`
// Page size
PageSize int `json:"page_size"`
// Offset
Offset int `json:"offset"`
// Sort field
Order string `json:"order"`
// Ascending order
IsAsc int `json:"is_asc"`
}
SearchResult represents search results
type ShareSnapResp ¶
type ShareSnapResp struct {
Userinfo struct {
UserID string `json:"user_id"`
UserName string `json:"user_name"`
Face string `json:"face"`
} `json:"userinfo"`
Shareinfo struct {
SnapID string `json:"snap_id"`
FileSize StringInt64 `json:"file_size"`
ShareTitle string `json:"share_title"`
ShareState StringInt64 `json:"share_state"`
ForbidReason string `json:"forbid_reason"`
CreateTime StringInt64 `json:"create_time"`
ReceiveCode string `json:"receive_code"`
ReceiveCount StringInt64 `json:"receive_count"`
ExpireTime int64 `json:"expire_time"`
FileCategory int64 `json:"file_category"`
AutoRenewal StringInt64 `json:"auto_renewal"`
AutoFillRecvcode StringInt64 `json:"auto_fill_recvcode"`
CanReport int `json:"can_report"`
CanNotice int `json:"can_notice"`
HaveVioFile int `json:"have_vio_file"`
} `json:"shareinfo"`
Count int `json:"count"`
List []ShareFile `json:"list"`
ShareState StringInt64 `json:"share_state"`
UserAppeal struct {
CanAppeal int `json:"can_appeal"`
CanShareAppeal int `json:"can_share_appeal"`
PopupAppealPage int `json:"popup_appeal_page"`
CanGlobalAppeal int `json:"can_global_appeal"`
} `json:"user_appeal"`
} `json:"data"`
}
type SharedDownloadInfo ¶
type SpaceInfo ¶
type SpaceInfo struct {
AllTotal TotalSize `json:"all_total"`
AllRemain RemainSize `json:"all_remain"`
AllUse UseSize `json:"all_use"`
}
type StringFloat64 ¶
type StringFloat64 float64
StringFloat64 uses for json field which maybe a string or a float64.
func (*StringFloat64) UnmarshalJSON ¶
func (v *StringFloat64) UnmarshalJSON(b []byte) (err error)
type StringInt ¶
type StringInt int64
StringInt uses for json field which maybe a string or an int.
func (*StringInt) UnmarshalJSON ¶
type StringInt64 ¶
type StringInt64 int64
StringInt64 uses for json field which maybe a string or an int64.
func (*StringInt64) UnmarshalJSON ¶
func (v *StringInt64) UnmarshalJSON(b []byte) (err error)
type StringTime ¶
type StringTime int64
func (*StringTime) UnmarshalJSON ¶
func (v *StringTime) UnmarshalJSON(b []byte) (err error)
type UploadEndpointResp ¶
type UploadInfoResp ¶
type UploadInfoResp struct {
BasicResp
UploadMetaInfo
UserID int64 `json:"user_id"`
Userkey string `json:"userkey"`
}
type UploadInitResp ¶
type UploadInitResp struct {
Request string `json:"request"`
ErrorCode int `json:"statuscode"`
ErrorMsg string `json:"statusmsg"`
Status BoolInt `json:"status"`
PickCode string `json:"pickcode"`
Target string `json:"target"`
Version string `json:"version"`
// OSS upload fields
UploadOSSParams
// Useless fields
FileID int `json:"fileid"`
FileInfo string `json:"fileinfo"`
// New fields in upload v4.0
SignKey string `json:"sign_key"`
SignCheck string `json:"sign_check"`
}
func (*UploadInitResp) Err ¶
func (r *UploadInitResp) Err(respBody ...string) error
func (*UploadInitResp) Ok ¶
func (r *UploadInitResp) Ok() (bool, error)
Ok if fastupload is successful will return true, otherwise return false
type UploadMetaInfo ¶
type UploadMetaInfo struct {
AppID int64 `json:"app_id"`
AppVersion int64 `json:"app_version"`
IspType int64 `json:"isp_type"`
MaxDirLevel int64 `json:"max_dir_level"`
MaxDirLevelYun int64 `json:"max_dir_level_yun"`
MaxFileNum int64 `json:"max_file_num"`
MaxFileNumYun int64 `json:"max_file_num_yun"`
SizeLimit int64 `json:"size_limit"`
SizeLimitYun int64 `json:"size_limit_yun"`
TypeLimit []string `json:"type_limit"`
UploadAllowed bool `json:"upload_allowed"`
UploadAllowedMsg string `json:"upload_allowed_msg"`
}
type UploadMultipartOption ¶
type UploadMultipartOption func(o *UploadMultipartOptions)
func UploadMultipartWithThreadsNum ¶
func UploadMultipartWithThreadsNum(n int) UploadMultipartOption
func UploadMultipartWithTimeout ¶
func UploadMultipartWithTimeout(timeout time.Duration) UploadMultipartOption
func UploadMultipartWithTokenRefreshTime ¶
func UploadMultipartWithTokenRefreshTime(refreshTime time.Duration) UploadMultipartOption
type UploadMultipartOptions ¶
type UploadMultipartOptions struct {
ThreadsNum int
Timeout time.Duration
TokenRefreshTime time.Duration
}
func DefalutUploadMultipartOptions ¶
func DefalutUploadMultipartOptions() *UploadMultipartOptions
DefaultUploadMultipartOptions typo of DefaultUploadMultipartOptions, for backward compatibility
func DefaultUploadMultipartOptions ¶
func DefaultUploadMultipartOptions() *UploadMultipartOptions
type UploadOSSParams ¶
type UploadOSSTokenResp ¶
type UploadOSSTokenResp struct {
AccessKeyID string `json:"AccessKeyID"`
AccessKeySecret string `json:"AccessKeySecret"`
Expiration time.Time `json:"Expiration"`
SecurityToken string `json:"SecurityToken"`
StatusCode string `json:"StatusCode"`
}
func (*UploadOSSTokenResp) Err ¶
func (r *UploadOSSTokenResp) Err(respBody ...string) error
type UploadResult ¶
type UploadResult struct {
BasicResp
Data struct {
PickCode string `json:"pick_code"`
FileSize int `json:"file_size"`
FileID string `json:"file_id"`
ThumbURL string `json:"thumb_url"`
Sha1 string `json:"sha1"`
Aid int `json:"aid"`
FileName string `json:"file_name"`
Cid string `json:"cid"`
IsVideo int `json:"is_video"`
} `json:"data"`
}
type UserInfo ¶
type UserInfo struct {
Device int `json:"device"`
Rank int `json:"rank"`
Liang int `json:"liang"`
Mark int `json:"mark"`
Mark1 int `json:"mark1"`
Vip int `json:"vip"`
Expire int `json:"expire"`
Global int `json:"global"`
Forever int `json:"forever"`
IsPrivilege bool `json:"is_privilege"`
Privilege Privilege `json:"privilege"`
UserName string `json:"user_name"`
Face string `json:"face"`
UserID int64 `json:"user_id"`
}
type UserInfoResp ¶
type VersionResp ¶
type VersionResp struct {
BasicResp
ErrCode int `json:"err_code,omitempty"`
Data Versions `json:"data"`
}
func (*VersionResp) Err ¶
func (resp *VersionResp) Err(respBody ...string) error
type Versions ¶
func (Versions) GetAppVersions ¶
func (v Versions) GetAppVersions() []AppVersion