Documentation
¶
Overview ¶
Index ¶
- Constants
- func Is401Started(code int64) bool
- func SliceContains[T comparable](s []T, e T) bool
- func Ternary[T any](condition bool, a T, b T) T
- type AuthDeviceCodeResp
- type AuthResp
- type Client
- func (c *Client) AuthDeviceCode(ctx context.Context, clientID string, codeVerifier string) (*AuthDeviceCodeResp, error)
- func (c *Client) AuthRequest(ctx context.Context, url, method string, respData any, opts ...RestyOption) (*resty.Response, error)
- func (c *Client) AuthRequestRaw(ctx context.Context, url, method string, respData any, opts ...RestyOption) (*resty.Response, error)
- func (c *Client) CodeToToken(ctx context.Context, uid, codeVerifier string) (*CodeToTokenResp, error)
- func (c *Client) Copy(ctx context.Context, req *CopyReq) (any, error)
- func (c *Client) DelFile(ctx context.Context, req *DelFileReq) ([]string, error)
- func (c *Client) DownURL(ctx context.Context, pickCode string, ua string) (DownURLResp, error)
- func (w *Client) EnableTrace() *Client
- func (c *Client) GetFiles(ctx context.Context, req *GetFilesReq) (*GetFilesResp, error)
- func (c *Client) GetFolderInfo(ctx context.Context, fileID string) (*GetFolderInfoResp, error)
- func (c *Client) Mkdir(ctx context.Context, pid, filename string) (*MkdirResp, error)
- func (c *Client) Move(ctx context.Context, req *MoveReq) (any, error)
- func (w *Client) NewRequest(ctx context.Context) *resty.Request
- func (c *Client) QrCodeStatus(ctx context.Context, uid, time, sign string) (*QrCodeStatusResp, error)
- func (c *Client) RbDelete(ctx context.Context, tid string) ([]string, error)
- func (c *Client) RbList(ctx context.Context, limit, offset int64) (*RbListResp, error)
- func (c *Client) RbRevert(ctx context.Context, tid string) (RbRevertResp, error)
- func (c *Client) RefreshToken(ctx context.Context) (*RefreshTokenResp, error)
- func (c *Client) Request(ctx context.Context, url string, method string, opts ...RestyOption) (*resty.Response, error)
- func (c *Client) SearchFiles(ctx context.Context, req *SearchFilesReq) (*SearchFilesResp, error)
- func (w *Client) SetAccessToken(token string) *Client
- func (w *Client) SetDebug(d bool) *Client
- func (w *Client) SetHttpClient(httpClient *http.Client) *Client
- func (w *Client) SetOnRefreshToken(fn func(accessToken string, refreshToken string)) *Client
- func (w *Client) SetProxy(proxy string) *Client
- func (w *Client) SetRefreshToken(token string) *Client
- func (w *Client) SetUserAgent(userAgent string) *Client
- func (c *Client) UpdateFile(ctx context.Context, req *UpdateFileReq) (*UpdateFileResp, error)
- func (c *Client) UploadGetToken(ctx context.Context) (*UploadGetTokenResp, error)
- func (c *Client) UploadInit(ctx context.Context, req *UploadInitReq) (*UploadInitResp, error)
- func (c *Client) UploadResume(ctx context.Context, req *UploadResumeReq) (*UploadResumeResp, error)
- func (c *Client) UserInfo(ctx context.Context) (*UserInfoResp, error)
- type CodeToTokenResp
- type CopyReq
- type DelFileReq
- type DownURLResp
- type Error
- type Form
- type GetFilesReq
- type GetFilesResp
- type GetFilesResp_File
- type GetFilesResp_File_FL
- type GetFolderInfoResp
- type Json
- type MkdirResp
- type MoveReq
- type Option
- type QrCodeStatusResp
- type RbListResp
- type RbListResp_FileInfo
- type RbRevertResp
- type RefreshTokenResp
- type Resp
- type RestyOption
- type SearchFilesReq
- type SearchFilesResp
- type UpdateFileReq
- type UpdateFileResp
- type UploadGetTokenResp
- type UploadInitReq
- type UploadInitResp
- type UploadResumeReq
- type UploadResumeResp
- type UserInfoResp
- type UserInfoResp_Size
Constants ¶
View Source
const ( ApiBaseURL = "https://proapi.115.com" ApiAuthURL = "https://passportapi.115.com" )
View Source
const ( ApiAuthDeviceCode = ApiAuthURL + "/open/authDeviceCode" ApiQrCodeStatus = "https://qrcodeapi.115.com/get/status/" ApiCodeToToken = ApiAuthURL + "/open/deviceCodeToToken" ApiRefreshToken = ApiAuthURL + "/open/refreshToken" )
Auth API
View Source
const ( ApiFsUploadGetToken = ApiBaseURL + "/open/upload/get_token" ApiFsUploadInit = ApiBaseURL + "/open/upload/init" ApiFsUploadResume = ApiBaseURL + "/open/upload/resume" ApiFsMkdir = ApiBaseURL + "/open/folder/add" ApiFsGetFiles = ApiBaseURL + "/open/ufile/files" ApiFsGetFolderInfo = ApiBaseURL + "/open/folder/get_info" ApiFsSearchFiles = ApiBaseURL + "/open/ufile/search" ApiFsCopy = ApiBaseURL + "/open/ufile/copy" ApiFsMove = ApiBaseURL + "/open/ufile/move" ApiFsDownURL = ApiBaseURL + "/open/ufile/downurl" ApiFsUpdate = ApiBaseURL + "/open/ufile/update" ApiFsDelete = ApiBaseURL + "/open/ufile/delete" ApiFsRbList = ApiBaseURL + "/open/rb/list" ApiFsRbRevert = ApiBaseURL + "/open/rb/revert" ApiFsRbDelete = ApiBaseURL + "/open/rb/del" )
File API
View Source
const (
ApiUserInfo = ApiBaseURL + "/open/user/info"
)
User API
Variables ¶
This section is empty.
Functions ¶
func Is401Started ¶
func SliceContains ¶
func SliceContains[T comparable](s []T, e T) bool
Types ¶
type AuthDeviceCodeResp ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AuthDeviceCode ¶
func (*Client) AuthRequest ¶
func (*Client) AuthRequestRaw ¶
func (*Client) CodeToToken ¶
func (*Client) EnableTrace ¶
func (*Client) GetFiles ¶
func (c *Client) GetFiles(ctx context.Context, req *GetFilesReq) (*GetFilesResp, error)
GetFiles: https://www.yuque.com/115yun/open/kz9ft9a7s57ep868
func (*Client) GetFolderInfo ¶
GetFolderInfo: https://www.yuque.com/115yun/open/rl8zrhe2nag21dfw
func (*Client) NewRequest ¶
func (*Client) QrCodeStatus ¶
func (*Client) RbRevert ¶
RbRevert: https://www.yuque.com/115yun/open/gq293z80a3kmxbaq
func (*Client) RefreshToken ¶
func (c *Client) RefreshToken(ctx context.Context) (*RefreshTokenResp, error)
func (*Client) SearchFiles ¶
func (c *Client) SearchFiles(ctx context.Context, req *SearchFilesReq) (*SearchFilesResp, error)
SearchFiles: https://www.yuque.com/115yun/open/ft2yelxzopusus38
func (*Client) SetAccessToken ¶
func (*Client) SetOnRefreshToken ¶
func (*Client) SetRefreshToken ¶
func (*Client) SetUserAgent ¶
func (*Client) UpdateFile ¶
func (c *Client) UpdateFile(ctx context.Context, req *UpdateFileReq) (*UpdateFileResp, error)
UpdateFile: https://www.yuque.com/115yun/open/gyrpw5a0zc4sengm
func (*Client) UploadGetToken ¶
func (c *Client) UploadGetToken(ctx context.Context) (*UploadGetTokenResp, error)
UploadGetToken: https://www.yuque.com/115yun/open/kzacvzl0g7aiyyn4
func (*Client) UploadInit ¶
func (c *Client) UploadInit(ctx context.Context, req *UploadInitReq) (*UploadInitResp, error)
UploadInit: https://www.yuque.com/115yun/open/ul4mrauo5i2uza0q
func (*Client) UploadResume ¶
func (c *Client) UploadResume(ctx context.Context, req *UploadResumeReq) (*UploadResumeResp, error)
UploadResume: https://www.yuque.com/115yun/open/tzvi9sbcg59msddz
func (*Client) UserInfo ¶
func (c *Client) UserInfo(ctx context.Context) (*UserInfoResp, error)
UserInfo: https://www.yuque.com/115yun/open/ot1litggzxa1czww
type CodeToTokenResp ¶
type DelFileReq ¶
type DownURLResp ¶
type GetFilesReq ¶
type GetFilesReq struct {
CID string
Type string
Limit int64
Offset int64
Suffix string
ASC bool // 1: asc, 0: desc
O string // order by file_name|file_size|user_utime|file_type
CustomOrder int
Stdir int // 筛选文件时, 是否显示文件夹;1:要展示文件夹 0不展示
Star bool // 1: filter star files
Cur int // 是否只显示当前文件夹内文件
ShowDir bool // 是否显示目录;0 或 1,默认为0
}
type GetFilesResp ¶
type GetFilesResp struct {
Resp[[]GetFilesResp_File]
Count int64 `json:"count"` // 当前目录文件数量
SysCount int64 `json:"sys_count"` // 系统文件夹数量
Offset int64 `json:"offset"` // 偏移量
Limit json.Number `json:"limit"` // 分页量
Aid int `json:"aid"` // 文件的状态,aid 的别名。1 正常,7 删除(回收站),120 彻底删除
Cid int64 `json:"cid"` // 父目录ID
IsAsc int `json:"is_asc"` // 1: asc, 0: desc
MinSize int64 `json:"min_size"`
MaxSize int64 `json:"max_size"`
SysDir string `json:"sys_dir"`
HideData string `json:"hide_data"` //是否返回文件数据
RecordOpenTime string `json:"record_open_time"` //是否记录文件夹的打开时间
Star int `json:"star"` //是否星标;1:星标;0:未星标
Type int `json:"type"` //一级筛选大分类,1:文档,2:图片,3:音乐,4:视频,5:压缩包,6:应用
Suffix string `json:"suffix"` //一级筛选选其他时填写的后缀名
Path []struct {
Name string `json:"name"` //父目录名
Aid json.Number `json:"aid"`
Cid json.Number `json:"cid"`
Pid json.Number `json:"pid"`
Isp json.Number `json:"isp"`
PCid string `json:"p_cid"`
Fv string `json:"fv"`
} `json:"path"` //父目录树
Cur int64 `json:"cur"`
StdDir int `json:"stdir"`
Fields string `json:"fields"`
Order string `json:"order"`
}
type GetFilesResp_File ¶
type GetFilesResp_File struct {
Fid string `json:"fid"` // 文件ID
Aid string `json:"aid"` // 文件的状态,aid 的别名。1 正常,7 删除(回收站),120 彻底删除
Pid string `json:"pid"` // 父文件夹ID
Fc string `json:"fc"` // 文件分类 0 文件夹 1 文件
Fn string `json:"fn"` // 文件名
Fco string `json:"fco"` // 文件夹封面
Ism string `json:"ism"` // 是否星标,1:星标
Isp int `json:"isp"` // 是否加密;1:加密
Pc string `json:"pc"` // 文件提取码
Upt int64 `json:"upt"` // 修改时间
Uet int64 `json:"uet"` // 修改时间
UpPt int64 `json:"uppt"` // 上传时间
Cm int64 `json:"cm"`
FDesc string `json:"fdesc"` // 文件备注
IsPl int64 `json:"ispl"` // 是否统计文件夹下视频时长开关
Fl []GetFilesResp_File_FL `json:"fl"` // 文件标签
Sha1 string `json:"sha1"` // 文件sha1
FS int64 `json:"fs"` // 文件大小
Fta string `json:"fta"` // 文件状态 0/2 未上传完成,1 已上传完成
Ico string `json:"ico"` // 文件后缀名
Fatr string `json:"fatr"` // 音频长度
IsV int64 `json:"isv"` // 是否视频文件
Def int64 `json:"def"` // 视频清晰度;1:标清 2:高清 3:超清 4:1080P 5:4k;100:原画
Def2 int64 `json:"def2"` // 视频清晰度;1:标清 2:高清 3:超清 4:1080P 5:4k;100:原画
PlayLong json.Number `json:"play_long"` // 音视频时长
VImg string `json:"v_img"`
Thumbnail string `json:"thumb"` // 图片缩略图
Uo string `json:"uo"` // 原图地址
}
type GetFilesResp_File_FL ¶
type GetFilesResp_File_FL struct {
Id string `json:"id"` // 文件标签ID
Name string `json:"name"` // 文件标签名称
Sort string `json:"sort"` // 文件标签排序
Color string `json:"color"` // 文件标签颜色
IsDefault int `json:"is_default"` // 文件标签类型;0:最近使用;1:非最近使用;2:为默认标签
UpdateTime int64 `json:"update_time"` // 文件标签更新时间
CreateTime int64 `json:"create_time"` // 文件标签创建时间
}
type GetFolderInfoResp ¶
type GetFolderInfoResp struct {
Count string `json:"count"`
Size string `json:"size"`
FolderCount int64 `json:"folder_count"`
PlayLong int64 `json:"play_long"`
ShowPlayLong int64 `json:"show_play_long"`
PTime string `json:"ptime"`
UTime string `json:"utime"`
FileName string `json:"file_name"`
PickCode string `json:"pick_code"`
Sha1 string `json:"sha1"`
FileID string `json:"file_id"`
IsMark string `json:"is_mark"`
OpenTime int64 `json:"open_time"`
FileCategory string `json:"file_category"`
Paths []struct {
FileID int64 `json:"file_id"`
FileName string `json:"file_name"`
} `json:"paths"`
}
type Option ¶
type Option func(*Client)
func WithAccessToken ¶
func WithOnRefreshToken ¶
func WithRefreshToken ¶
func WithRestyClient ¶
func WithRestyClient(rc *resty.Client) Option
type QrCodeStatusResp ¶
type RbListResp ¶
type RbListResp_FileInfo ¶
type RbListResp_FileInfo struct {
ID string `json:"id"`
FileName string `json:"file_name"`
Type string `json:"type"`
FileSize string `json:"file_size"`
Dtime string `json:"dtime"`
ThumbURL string `json:"thumb_url"`
Status string `json:"status"`
CID string `json:"cid"`
ParentName string `json:"parent_name"`
PickCode string `json:"pick_code"`
IsV int `json:"isv"`
Ico string `json:"ico"`
Muc string `json:"muc"`
DImg string `json:"d_img"`
SHA1 string `json:"sha1"`
}
type RbRevertResp ¶
type RefreshTokenResp ¶
type RefreshTokenResp CodeToTokenResp
type RestyOption ¶
type RestyOption func(request *resty.Request)
func ReqWithForm ¶
func ReqWithForm(form Form) RestyOption
func ReqWithJson ¶
func ReqWithJson(json any) RestyOption
func ReqWithQuery ¶
func ReqWithQuery(query Form) RestyOption
func ReqWithResp ¶
func ReqWithResp(v any) RestyOption
func ReqWithUA ¶
func ReqWithUA(ua string) RestyOption
type SearchFilesReq ¶
type SearchFilesReq struct {
SearchValue string //查找关键字
Limit int64 //单页记录数,默认20,offset+limit最大不超过10000
Offset int64 //数据显示偏移量
FileLabel string //支持文件标签搜索
CID string //目标目录cid=-1时,表示不返回列表任何内容
GteDay string //搜索结果匹配的开始时间;格式:2020-11-19
LteDay string //搜索结果匹配的结束时间;格式:2020-11-20
FC string //只显示文件或文件夹。1 只显示文件夹,2 只显示文件
Type string //一级筛选大分类,1:文档,2:图片,3:音乐,4:视频,5:压缩包,6:应用
Suffix string //一级筛选选其他时填写的后缀名
}
type SearchFilesResp ¶
type SearchFilesResp struct {
Resp[[]struct {
FileID string `json:"file_id"` // 文件ID
UserID string `json:"user_id"` // 用户ID
Sha1 string `json:"sha1"` // 文件sha1值
FileName string `json:"file_name"` // 文件名称
FileSize string `json:"file_size"` // 文件大小
UserPtime string `json:"user_ptime"` // 上传时间
UserUtime string `json:"user_utime"` // 更新时间
PickCode string `json:"pick_code"` // 文件提取码
ParentID string `json:"parent_id"` // 父目录ID
AreaID string `json:"area_id"` // 文件的状态,aid 的别名。1 正常,7 删除(回收站),120 彻底删除
IsPrivate int `json:"is_private"` // 文件是否隐藏。0 未隐藏,1 已隐藏
FileCategory string `json:"file_category"` // 1:文件;0;文件夹
Ico string `json:"ico"` // 文件后缀名
}]
Count int64 `json:"count"` // 搜索符合条件的文件(夹)总数
Limit int64 `json:"limit"` // 单页记录数
Offset int64 `json:"offset"` // 数据显示偏移量
}
type UpdateFileReq ¶
type UpdateFileResp ¶
type UploadGetTokenResp ¶
type UploadInitReq ¶
type UploadInitReq struct {
FileName string `json:"file_name"`
FileSize int64 `json:"file_size"`
Target string `json:"target"`
FileID string `json:"fileid"` // 文件Sha1
PreID string `json:"preid"` // 文件前128k的sha1
PickCode string `json:"pick_code"`
TopUpload string `json:"topupload"`
SignKey string `json:"sign_key"`
SignVal string `json:"sign_val"`
}
type UploadInitResp ¶
type UploadInitResp struct {
PickCode string `json:"pick_code"`
Status int `json:"status"`
SignKey string `json:"sign_key"`
SignCheck string `json:"sign_check"`
FileID string `json:"file_id"`
Target string `json:"target"`
Bucket string `json:"bucket"`
Object string `json:"object"`
Callback json_types.StructOrArray[struct {
Callback string `json:"callback"`
CallbackVar string `json:"callback_var"`
}] `json:"callback"`
}
type UploadResumeReq ¶
type UploadResumeResp ¶
type UploadResumeResp struct {
PickCode string `json:"pick_code"`
Target string `json:"target"`
Version string `json:"version"`
Bucket string `json:"bucket"`
Object string `json:"object"`
Callback json_types.StructOrArray[struct {
Callback string `json:"callback"`
CallbackVar string `json:"callback_var"`
}] `json:"callback"`
}
type UserInfoResp ¶
type UserInfoResp struct {
UserID int64 `json:"user_id"`
UserName string `json:"user_name"`
UserFaceS string `json:"user_face_s"`
UserFaceM string `json:"user_face_m"`
UserFaceL string `json:"user_face_l"`
RtSpaceInfo struct {
AllTotal UserInfoResp_Size `json:"all_total"`
AllRemain UserInfoResp_Size `json:"all_remain"`
AllUse UserInfoResp_Size `json:"all_use"`
} `json:"rt_space_info"`
VipInfo struct {
LevelName string `json:"level_name"`
Expire int64 `json:"expire"`
} `json:"vip_info"`
}
type UserInfoResp_Size ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.