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 AppVersion
- type BasicResp
- type BoolInt
- type Credential
- type DataString
- 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 IntString
- type Label
- type LabelColor
- type LabelInfo
- type LoginApp
- type LoginResp
- type MkdirResp
- type OfflineAddUrlResponse
- type OfflineTask
- type OfflineTaskResp
- type OfflineTaskResponse
- type Option
- type Pan115Client
- func (c *Pan115Client) AddOfflineTaskURIs(uris []string, saveDirID string) (hashes []string, err error)
- func (c *Pan115Client) CleanRecycleBin(password string, rIDs ...string) error
- func (c *Pan115Client) ClearOfflineTasks(clearFlag int64) 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) 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) 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) 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) (*[]File, error)
- func (c *Pan115Client) ListOfflineTask(page int64) (OfflineTaskResp, error)
- func (c *Pan115Client) ListPage(dirID string, offset, limit int64) (*[]File, error)
- func (c *Pan115Client) ListRecycleBin(offset, limit int) ([]RecycleBinItem, error)
- func (c *Pan115Client) ListWithLimit(dirID string, limit int64) (*[]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) 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 QRCodeBasicResp
- type QRCodeLoginResp
- type QRCodeSession
- type QRCodeStatus
- type QRCodeStatusResp
- type QRCodeTokenResp
- type Query
- type RecycleBinItem
- type RecycleListResponse
- type ResultWithErr
- type ShareFile
- type ShareSnapResp
- type SharedDownloadInfo
- type StringFloat64
- type StringInt
- type StringInt64
- type StringTime
- type Time
- type UploadEndpointResp
- type UploadInfoResp
- type UploadInitResp
- type UploadMetaInfo
- type UploadMultipartOption
- type UploadMultipartOptions
- type UploadOSSParams
- type UploadOSSTokenResp
- 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" // dir ApiDirAdd = "https://webapi.115.com/files/add" // 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" ApiFileList = "https://webapi.115.com/files" ApiFileListByName = "https://aps.115.com/natsort/files.php" ApiFileStat = "https://webapi.115.com/category/get" ApiFileInfo = "https://webapi.115.com/files/get_info" ApiShareSnap = "https://webapi.115.com/share/snap" // download ApiDownloadGetUrl = "https://proapi.115.com/app/chrome/downurl" // 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" )
const ( UADefalut = "Mozilla/5.0" UA115Browser = "Mozilla/5.0 115Browser/27.0.3.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") ErrDownloadDirectory = errors.New("can not download directory") 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
Functions ¶
func CheckErr ¶
func CheckErr(err error, result ResultWithErr, restyResp *resty.Response) error
func OssOption ¶
func OssOption(params *UploadOSSParams, ossToken *UploadOSSTokenResp) []oss.Option
OssOption get options
Types ¶
type AppVersion ¶
type BasicResp ¶
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 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"` }
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) 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 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 Label ¶
type Label struct { ID string Name string Color LabelColor }
type LabelColor ¶
type LabelColor int
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 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 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 ¶
func WithRestyClient(resty *resty.Client) Option
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) (hashes []string, err error)
AddOfflineTaskURIs adds offline tasks by download URIs. supports http, ed2k, magent
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) Copy ¶
func (c *Pan115Client) Copy(dirID string, fileIDs ...string) error
Copy copy files or directory into another directory with directroy id
Example ¶
client := Defalut() err := client.Copy("dirID", "fileID") if err != nil { log.Fatalf("Copy file error: %s", err) }
Output:
func (*Pan115Client) Delete ¶
func (c *Pan115Client) Delete(fileIDs ...string) error
Delete delete files or directory from file ids
Example ¶
client := Defalut() err := client.Delete("fileID") if err != nil { log.Fatalf("Delete file error: %s", err) }
Output:
func (*Pan115Client) DeleteOfflineTasks ¶
func (c *Pan115Client) DeleteOfflineTasks(hashes []string, deleteFiles bool) error
DeleteOfflineTasks deletes tasks.
func (*Pan115Client) Download ¶
func (c *Pan115Client) Download(pickCode string) (*DownloadInfo, error)
Download get download info with pickcode
Example ¶
client := Defalut() 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) }
Output:
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) 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) 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 := Defalut().ImportCredential(cr) if err := client.LoginCheck(); err != nil { log.Fatalf("Login error: %s", err) }
Output:
func (*Pan115Client) List ¶
func (c *Pan115Client) List(dirID string) (*[]File, error)
List list all files and directories
Example ¶
client := Defalut() files, err := client.List("dirID") if err != nil { log.Fatalf("List file error: %s", err) } for _, file := range *files { log.Printf("file %v", file) }
Output:
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) (*[]File, 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) (*[]File, error)
ListWithLimit list all files and directories with limit
func (*Pan115Client) LoginCheck ¶
func (c *Pan115Client) LoginCheck() error
LoginCheck check login status
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 := Defalut() cid, err := client.Mkdir("parentID", "name") if err != nil { log.Fatalf("Make directory error: %s", err) } log.Printf("cid is %s", cid)
Output:
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 := Defalut() err := client.Move("dirID", "fileID") if err != nil { log.Fatalf("Move file error: %s", err) }
Output:
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 := Defalut() err := client.Rename("fileID", "newname") if err != nil { log.Fatalf("Rename file error: %s", err) }
Output:
func (*Pan115Client) RevertRecycleBin ¶
func (c *Pan115Client) RevertRecycleBin(rIDs ...string) error
RevertRecycleBin revert the recycle bin
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 := Defalut() 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) }
Output:
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 := Defalut() 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") }
Output:
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 ResultWithErr ¶
type ShareSnapResp ¶
type ShareSnapResp struct { 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 string `json:"share_state"` ForbidReason string `json:"forbid_reason"` CreateTime StringInt64 `json:"create_time"` ReceiveCode string `json:"receive_code"` ReceiveCount string `json:"receive_count"` ExpireTime int64 `json:"expire_time"` FileCategory int64 `json:"file_category"` AutoRenewal string `json:"auto_renewal"` AutoFillRecvcode string `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 string `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"` }Userinfo struct { UserID
type SharedDownloadInfo ¶
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
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 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 []interface{} `json:"privilege"` UserName string `json:"user_name"` Face string `json:"face"` UserID int64 `json:"user_id"` }
type UserInfoResp ¶
type VersionResp ¶
type Versions ¶
func (Versions) GetAppVersions ¶
func (v Versions) GetAppVersions() []AppVersion