Documentation
¶
Index ¶
- type APIResponse
- type FileInfo
- type FileInfoRequest
- type HTTPRequest
- type ListRequest
- type ListResponse
- type LoginRequest
- type LoginResponse
- type MkdirRequest
- type OpenListAPI
- func (c *OpenListAPI) DownloadFile(remotePath, localPath string, progressFunc ProgressFunc) error
- func (c *OpenListAPI) GetFileInfo(filePath string) (*FileInfo, error)
- func (c *OpenListAPI) ListFiles(path string, page, perPage int, refresh bool) (*ListResponse, error)
- func (c *OpenListAPI) Login() (bool, error)
- func (c *OpenListAPI) Mkdir(path string) error
- func (c *OpenListAPI) Mkdirs(path string) error
- func (c *OpenListAPI) Remove(dir string, names []string) error
- func (c *OpenListAPI) ResetProxyStatus()
- func (c *OpenListAPI) SearchFiles(keyword, parentPath string) (*SearchResult, error)
- func (c *OpenListAPI) TestProxy() bool
- func (c *OpenListAPI) UploadFile(filePath, remotePath string) (string, error)
- type ProgressFunc
- type ProgressReader
- type RemoveRequest
- type SearchRequest
- type SearchResult
- type UploadRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse struct {
Code int `json:"code"` // 状态码(200为成功)
Message string `json:"message"` // 描述信息
Data interface{} `json:"data"` // 业务数据(动态解析)
}
APIResponse 通用API响应结构体(用于解析非登录接口的返回)
type FileInfo ¶
type FileInfo struct {
Name string `json:"name"` // 文件名
Size int64 `json:"size"` // 文件大小(字节)
IsDir bool `json:"is_dir"` // 是否为目录
Modified time.Time `json:"modified"` // 修改时间
Created time.Time `json:"created"`
Sign string `json:"sign"`
Thumb string `json:"thumb"`
Type int64 `json:"type"`
HashInfo interface{} `json:"hashinfo"`
Hash_info interface{} `json:"hash_info"`
//list没有get才有
Raw_url string `json:"raw_url"`
Related interface{} `json:"related"`
}
FileInfo 文件信息结构体(对应原Python的Dict返回)
type FileInfoRequest ¶
FileInfoRequest 获取文件信息请求参数
type HTTPRequest ¶
type HTTPRequest struct {
Method string // HTTP方法 (GET, POST, PUT, DELETE等)
URL string // 请求URL
Body interface{} // 请求体数据(会自动序列化为JSON)
Headers map[string]string // 请求头
}
HTTPRequest 通用HTTP请求配置
type ListRequest ¶
type ListRequest struct {
Path string `json:"path"`
Password string `json:"password"`
Page int `json:"page"`
PerPage int `json:"per_page"`
Refresh bool `json:"refresh"`
}
ListRequest 列表请求参数
type ListResponse ¶
type ListResponse struct {
Content []FileInfo `json:"content"` // 文件/目录列表
Total int `json:"total"` // 总数量
Page int `json:"page"` // 当前页码
PerPage int `json:"per_page"` // 每页条数
Write bool `json:"write"`
Provider string `json:"provider"`
Readme string `json:"readme"`
Header string `json:"header"`
}
ListResponse 目录列表响应结构体
type LoginRequest ¶
LoginRequest 登录请求参数
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"` // 登录令牌
}
LoginResponse 登录接口响应结构体
type MkdirRequest ¶ added in v1.0.4
type MkdirRequest struct {
Path string `json:"path"` // 新目录路径
}
MkdirRequest 创建文件夹请求参数
type OpenListAPI ¶
type OpenListAPI struct {
// contains filtered or unexported fields
}
OpenListAPI OpenList 服务客户端
func NewOpenListAPI ¶
func NewOpenListAPI(baseURL, username, password, proxy string) *OpenListAPI
NewOpenListAPI 创建OpenListAPI客户端实例
func (*OpenListAPI) DownloadFile ¶
func (c *OpenListAPI) DownloadFile(remotePath, localPath string, progressFunc ProgressFunc) error
DownloadFile 从OpenList服务下载文件 remotePath: 远程文件路径(如 "/docs/test.txt") localPath: 本地保存路径 progressFunc: 进度回调函数(可选) 返回值: 错误信息
func (*OpenListAPI) GetFileInfo ¶
func (c *OpenListAPI) GetFileInfo(filePath string) (*FileInfo, error)
GetFileInfo 获取文件信息(含下载地址) filePath: 远程文件路径(如 "/docs/test.txt") 返回值: 文件信息结构体,错误信息
func (*OpenListAPI) ListFiles ¶
func (c *OpenListAPI) ListFiles(path string, page, perPage int, refresh bool) (*ListResponse, error)
ListFiles 列出目录下的文件/目录 path: 目录路径(默认 "/") page: 页码(默认 1) perPage: 每页条数(0表示不分页) refresh: 是否强制刷新(默认 true) 返回值: 目录列表响应,错误信息
func (*OpenListAPI) Mkdir ¶ added in v1.0.4
func (c *OpenListAPI) Mkdir(path string) error
Mkdir 创建文件夹 path: 新目录路径 返回值: 错误信息
func (*OpenListAPI) Mkdirs ¶ added in v1.0.4
func (c *OpenListAPI) Mkdirs(path string) error
Mkdir 创建文件夹 path: 新目录路径 返回值: 错误信息
func (*OpenListAPI) Remove ¶
func (c *OpenListAPI) Remove(dir string, names []string) error
Remove 删除文件或文件夹 dir: 目录路径 names: 要删除的文件或文件夹名称列表 返回值: 错误信息
func (*OpenListAPI) ResetProxyStatus ¶
func (c *OpenListAPI) ResetProxyStatus()
ResetProxyStatus 重置代理状态(修改代理配置后调用,重新测试)
func (*OpenListAPI) SearchFiles ¶
func (c *OpenListAPI) SearchFiles(keyword, parentPath string) (*SearchResult, error)
SearchFiles 搜索文件 keyword: 搜索关键词 parentPath: 搜索父目录(默认 "/") 返回值: 搜索结果列表,错误信息
func (*OpenListAPI) UploadFile ¶
func (c *OpenListAPI) UploadFile(filePath, remotePath string) (string, error)
UploadFile 上传文件到OpenList服务 filePaths: 本地文件路径 remotePath: 远程存储目录(如 "/docs") 返回值: 远程文件完整路径(如 "/docs/test.txt"),错误信息
type ProgressFunc ¶
type ProgressFunc func(downloaded, total int64)
ProgressFunc 进度回调函数类型 参数: 已下载字节数, 总字节数
type ProgressReader ¶
type ProgressReader struct {
// contains filtered or unexported fields
}
ProgressReader 带进度回调的Reader
type RemoveRequest ¶
RemoveRequest 删除文件或文件夹请求参数
type SearchRequest ¶
type SearchRequest struct {
Parent string `json:"parent"`
Keywords string `json:"keywords"`
Scope int `json:"scope" default:"0"`
Page int `json:"page" default:"1"`
Per_page int `json:"per_page" default:"50"`
}
SearchRequest 搜索文件请求参数
type SearchResult ¶
type SearchResult struct {
Content []struct {
Parent string `json:"parent"`
Name string `json:"name"` // 文件名
IsDir bool `json:"is_dir"` // 是否为目录
Size int64 `json:"size"` // 文件大小(字节)
Type int64 `json:"type"`
}
}
SearchResult 搜索结果结构体
type UploadRequest ¶
type UploadRequest struct {
FilePath string `json:"file_path"`
RemotePath string `json:"remote_path"`
}
UploadRequest 上传文件请求参数