Documentation
¶
Overview ¶
Copyright (c) 2020 tickstep.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func DeleteLocalFile(localFilePath string) bool
- func DeletePanFile(userId, driveId, panFileId string) bool
- func GetString(key string) string
- func HttpGet(header map[string]string, url string) string
- func HttpPost(header map[string]string, url string, data interface{}) string
- func Md5Hex(text string) string
- func PutString(key, value string) bool
- func SendHtmlMail(mailServer, userName, password, to, subject, body string) bool
- func SendTextMail(mailServer, userName, password, to, subject, body string) bool
- type Context
- type DownloadFileFinishParams
- type DownloadFilePrepareParams
- type DownloadFilePrepareResult
- type IdlePlugin
- func (p *IdlePlugin) DownloadFileFinishCallback(context *Context, params *DownloadFileFinishParams) error
- func (p *IdlePlugin) DownloadFilePrepareCallback(context *Context, params *DownloadFilePrepareParams) (*DownloadFilePrepareResult, error)
- func (p *IdlePlugin) RemoveFilePrepareCallback(context *Context, params *RemoveFilePrepareParams) (*RemoveFilePrepareResult, error)
- func (p *IdlePlugin) Start() error
- func (p *IdlePlugin) Stop() error
- func (p *IdlePlugin) SyncAllFileFinishCallback(context *Context, params *SyncAllFileFinishParams) error
- func (p *IdlePlugin) SyncFileFinishCallback(context *Context, params *SyncFileFinishParams) error
- func (p *IdlePlugin) SyncScanLocalFilePrepareCallback(context *Context, params *SyncScanLocalFilePrepareParams) (*SyncScanLocalFilePrepareResult, error)
- func (p *IdlePlugin) SyncScanPanFilePrepareCallback(context *Context, params *SyncScanPanFilePrepareParams) (*SyncScanPanFilePrepareResult, error)
- func (p *IdlePlugin) UploadFileFinishCallback(context *Context, params *UploadFileFinishParams) error
- func (p *IdlePlugin) UploadFilePrepareCallback(context *Context, params *UploadFilePrepareParams) (*UploadFilePrepareResult, error)
- func (p *IdlePlugin) UserTokenRefreshFinishCallback(context *Context, params *UserTokenRefreshFinishParams) error
- type JsPlugin
- func (js *JsPlugin) DownloadFileFinishCallback(context *Context, params *DownloadFileFinishParams) error
- func (js *JsPlugin) DownloadFilePrepareCallback(context *Context, params *DownloadFilePrepareParams) (*DownloadFilePrepareResult, error)
- func (js *JsPlugin) LoadScript(script string) error
- func (js *JsPlugin) RemoveFilePrepareCallback(context *Context, params *RemoveFilePrepareParams) (*RemoveFilePrepareResult, error)
- func (js *JsPlugin) Start() error
- func (js *JsPlugin) Stop() error
- func (js *JsPlugin) SyncAllFileFinishCallback(context *Context, params *SyncAllFileFinishParams) error
- func (js *JsPlugin) SyncFileFinishCallback(context *Context, params *SyncFileFinishParams) error
- func (js *JsPlugin) SyncScanLocalFilePrepareCallback(context *Context, params *SyncScanLocalFilePrepareParams) (*SyncScanLocalFilePrepareResult, error)
- func (js *JsPlugin) SyncScanPanFilePrepareCallback(context *Context, params *SyncScanPanFilePrepareParams) (*SyncScanPanFilePrepareResult, error)
- func (js *JsPlugin) UploadFileFinishCallback(context *Context, params *UploadFileFinishParams) error
- func (js *JsPlugin) UploadFilePrepareCallback(context *Context, params *UploadFilePrepareParams) (*UploadFilePrepareResult, error)
- func (js *JsPlugin) UserTokenRefreshFinishCallback(context *Context, params *UserTokenRefreshFinishParams) error
- type PersistenceItem
- type Plugin
- type PluginManager
- type RemoveFilePrepareItem
- type RemoveFilePrepareParams
- type RemoveFilePrepareResult
- type RemoveFilePrepareResultItem
- type SyncAllFileFinishParams
- type SyncFileFinishParams
- type SyncScanLocalFilePrepareParams
- type SyncScanLocalFilePrepareResult
- type SyncScanPanFilePrepareParams
- type SyncScanPanFilePrepareResult
- type UploadFileFinishParams
- type UploadFilePrepareParams
- type UploadFilePrepareResult
- type UserTokenRefreshFinishParams
Constants ¶
This section is empty.
Variables ¶
var (
PersistenceFilePath = ""
)
Functions ¶
func DeleteLocalFile ¶
DeleteLocalFile 删除本地文件,不支持文件夹
func DeletePanFile ¶ added in v0.3.7
DeletePanFile 删除云盘文件,支持文件和文件夹
func SendHtmlMail ¶ added in v0.2.4
SendHtmlMail 发送HTML富文本邮件
func SendTextMail ¶ added in v0.2.4
SendTextMail 发送文本邮件
Types ¶
type Context ¶
type Context struct { AppName string `json:"appName"` Version string `json:"version"` UserId string `json:"userId"` Nickname string `json:"nickname"` // FileDriveId 备份盘 FileDriveId string `json:"fileDriveId"` // AlbumDriveId 相册盘 AlbumDriveId string `json:"albumDriveId"` // ResourceDriveId 资源盘 ResourceDriveId string `json:"resourceDriveId"` }
Context 插件回调函数上下文信息
func GetContext ¶
type DownloadFileFinishParams ¶
type DownloadFileFinishParams struct { DriveId string `json:"driveId"` DriveFileId string `json:"driveFileId"` DriveFileName string `json:"driveFileName"` DriveFilePath string `json:"driveFilePath"` DriveFileSha1 string `json:"driveFileSha1"` DriveFileSize int64 `json:"driveFileSize"` DriveFileType string `json:"driveFileType"` DriveFileUpdatedAt string `json:"driveFileUpdatedAt"` DownloadResult string `json:"downloadResult"` LocalFilePath string `json:"localFilePath"` DownloadActionId string `json:"downloadActionId"` }
DownloadFileFinishParams 下载文件结束的回调函数-参数
type DownloadFilePrepareParams ¶
type DownloadFilePrepareParams struct { DriveId string `json:"driveId"` DriveFileName string `json:"driveFileName"` DriveFilePath string `json:"driveFilePath"` DriveFileSha1 string `json:"driveFileSha1"` DriveFileSize int64 `json:"driveFileSize"` DriveFileType string `json:"driveFileType"` DriveFileUpdatedAt string `json:"driveFileUpdatedAt"` LocalFilePath string `json:"localFilePath"` DownloadActionId string `json:"downloadActionId"` }
DownloadFilePrepareParams 下载文件前的回调函数-参数
type DownloadFilePrepareResult ¶
type DownloadFilePrepareResult struct { // DownloadApproved 确认该文件是否下载。yes-下载 no-不下载 DownloadApproved string `json:"downloadApproved"` // LocalFilePath 保存本地的修改后的路径。注意该路径是相对路径 LocalFilePath string `json:"localFilePath"` }
DownloadFilePrepareResult 上传文件前的回调函数-返回结果
type IdlePlugin ¶
type IdlePlugin struct {
Name string
}
func NewIdlePlugin ¶
func NewIdlePlugin() *IdlePlugin
func (*IdlePlugin) DownloadFileFinishCallback ¶
func (p *IdlePlugin) DownloadFileFinishCallback(context *Context, params *DownloadFileFinishParams) error
func (*IdlePlugin) DownloadFilePrepareCallback ¶
func (p *IdlePlugin) DownloadFilePrepareCallback(context *Context, params *DownloadFilePrepareParams) (*DownloadFilePrepareResult, error)
func (*IdlePlugin) RemoveFilePrepareCallback ¶ added in v0.3.7
func (p *IdlePlugin) RemoveFilePrepareCallback(context *Context, params *RemoveFilePrepareParams) (*RemoveFilePrepareResult, error)
func (*IdlePlugin) Start ¶
func (p *IdlePlugin) Start() error
func (*IdlePlugin) Stop ¶
func (p *IdlePlugin) Stop() error
func (*IdlePlugin) SyncAllFileFinishCallback ¶ added in v0.3.7
func (p *IdlePlugin) SyncAllFileFinishCallback(context *Context, params *SyncAllFileFinishParams) error
func (*IdlePlugin) SyncFileFinishCallback ¶ added in v0.2.3
func (p *IdlePlugin) SyncFileFinishCallback(context *Context, params *SyncFileFinishParams) error
func (*IdlePlugin) SyncScanLocalFilePrepareCallback ¶ added in v0.1.6
func (p *IdlePlugin) SyncScanLocalFilePrepareCallback(context *Context, params *SyncScanLocalFilePrepareParams) (*SyncScanLocalFilePrepareResult, error)
func (*IdlePlugin) SyncScanPanFilePrepareCallback ¶ added in v0.1.6
func (p *IdlePlugin) SyncScanPanFilePrepareCallback(context *Context, params *SyncScanPanFilePrepareParams) (*SyncScanPanFilePrepareResult, error)
func (*IdlePlugin) UploadFileFinishCallback ¶
func (p *IdlePlugin) UploadFileFinishCallback(context *Context, params *UploadFileFinishParams) error
func (*IdlePlugin) UploadFilePrepareCallback ¶
func (p *IdlePlugin) UploadFilePrepareCallback(context *Context, params *UploadFilePrepareParams) (*UploadFilePrepareResult, error)
func (*IdlePlugin) UserTokenRefreshFinishCallback ¶ added in v0.2.4
func (p *IdlePlugin) UserTokenRefreshFinishCallback(context *Context, params *UserTokenRefreshFinishParams) error
type JsPlugin ¶
type JsPlugin struct { Name string // contains filtered or unexported fields }
func NewJsPlugin ¶
func NewJsPlugin() *JsPlugin
func (*JsPlugin) DownloadFileFinishCallback ¶
func (js *JsPlugin) DownloadFileFinishCallback(context *Context, params *DownloadFileFinishParams) error
DownloadFileFinishCallback 下载文件结束的回调函数
func (*JsPlugin) DownloadFilePrepareCallback ¶
func (js *JsPlugin) DownloadFilePrepareCallback(context *Context, params *DownloadFilePrepareParams) (*DownloadFilePrepareResult, error)
DownloadFilePrepareCallback 下载文件前的回调函数
func (*JsPlugin) RemoveFilePrepareCallback ¶ added in v0.3.7
func (js *JsPlugin) RemoveFilePrepareCallback(context *Context, params *RemoveFilePrepareParams) (*RemoveFilePrepareResult, error)
RemoveFilePrepareCallback 删除文件前的回调函数
func (*JsPlugin) SyncAllFileFinishCallback ¶ added in v0.3.7
func (js *JsPlugin) SyncAllFileFinishCallback(context *Context, params *SyncAllFileFinishParams) error
SyncAllFileFinishCallback 同步备份-同步全部文件完成时的回调函数
func (*JsPlugin) SyncFileFinishCallback ¶ added in v0.2.3
func (js *JsPlugin) SyncFileFinishCallback(context *Context, params *SyncFileFinishParams) error
SyncFileFinishCallback 同步备份-同步文件完成的回调函数
func (*JsPlugin) SyncScanLocalFilePrepareCallback ¶ added in v0.1.6
func (js *JsPlugin) SyncScanLocalFilePrepareCallback(context *Context, params *SyncScanLocalFilePrepareParams) (*SyncScanLocalFilePrepareResult, error)
SyncScanLocalFilePrepareCallback 同步备份-扫描本地文件的回调函数
func (*JsPlugin) SyncScanPanFilePrepareCallback ¶ added in v0.1.6
func (js *JsPlugin) SyncScanPanFilePrepareCallback(context *Context, params *SyncScanPanFilePrepareParams) (*SyncScanPanFilePrepareResult, error)
SyncScanPanFilePrepareCallback 同步备份-扫描本地文件的回调函数
func (*JsPlugin) UploadFileFinishCallback ¶
func (js *JsPlugin) UploadFileFinishCallback(context *Context, params *UploadFileFinishParams) error
UploadFileFinishCallback 上传文件结束的回调函数
func (*JsPlugin) UploadFilePrepareCallback ¶
func (js *JsPlugin) UploadFilePrepareCallback(context *Context, params *UploadFilePrepareParams) (*UploadFilePrepareResult, error)
UploadFilePrepareCallback 上传文件前的回调函数
func (*JsPlugin) UserTokenRefreshFinishCallback ¶ added in v0.2.4
func (js *JsPlugin) UserTokenRefreshFinishCallback(context *Context, params *UserTokenRefreshFinishParams) error
UserTokenRefreshFinishCallback 用户Token刷新完成后回调函数
type PersistenceItem ¶ added in v0.2.4
type Plugin ¶
type Plugin interface { // Start 启动 Start() error // UploadFilePrepareCallback 上传文件前的回调函数 UploadFilePrepareCallback(context *Context, params *UploadFilePrepareParams) (*UploadFilePrepareResult, error) // UploadFileFinishCallback 上传文件结束的回调函数 UploadFileFinishCallback(context *Context, params *UploadFileFinishParams) error // DownloadFilePrepareCallback 下载文件前的回调函数 DownloadFilePrepareCallback(context *Context, params *DownloadFilePrepareParams) (*DownloadFilePrepareResult, error) // DownloadFileFinishCallback 下载文件结束的回调函数 DownloadFileFinishCallback(context *Context, params *DownloadFileFinishParams) error // SyncScanLocalFilePrepareCallback 同步备份-扫描本地文件的回调函数 SyncScanLocalFilePrepareCallback(context *Context, params *SyncScanLocalFilePrepareParams) (*SyncScanLocalFilePrepareResult, error) // SyncScanPanFilePrepareCallback 同步备份-扫描云盘文件的回调函数 SyncScanPanFilePrepareCallback(context *Context, params *SyncScanPanFilePrepareParams) (*SyncScanPanFilePrepareResult, error) // SyncFileFinishCallback 同步备份-同步一个文件完成时的回调函数 SyncFileFinishCallback(context *Context, params *SyncFileFinishParams) error // SyncAllFileFinishCallback 同步备份-同步全部文件完成时的回调函数 SyncAllFileFinishCallback(context *Context, params *SyncAllFileFinishParams) error // UserTokenRefreshFinishCallback 用户Token刷新完成后回调函数 UserTokenRefreshFinishCallback(context *Context, params *UserTokenRefreshFinishParams) error // RemoveFilePrepareCallback 删除文件前的回调函数 RemoveFilePrepareCallback(context *Context, params *RemoveFilePrepareParams) (*RemoveFilePrepareResult, error) // Stop 停止 Stop() error }
Plugin 插件接口
type PluginManager ¶
type PluginManager struct {
PluginPath string
}
func NewPluginManager ¶
func NewPluginManager(pluginDir string) *PluginManager
func (*PluginManager) GetPlugin ¶
func (p *PluginManager) GetPlugin() (Plugin, error)
func (*PluginManager) SetPluginPath ¶
func (p *PluginManager) SetPluginPath(pluginPath string) error
type RemoveFilePrepareItem ¶ added in v0.3.7
type RemoveFilePrepareItem struct { // DriveId 网盘ID DriveId string `json:"driveId"` // DriveFileId 网盘文件的ID DriveFileId string `json:"driveFileId"` // DriveFileName 网盘文件名 DriveFileName string `json:"driveFileName"` // DriveFilePath 网盘文件路径 DriveFilePath string `json:"driveFilePath"` // DriveFileSize 网盘文件大小 DriveFileSize int64 `json:"driveFileSize"` // DriveFileType 网盘文件类型,file-文件,folder-文件夹 DriveFileType string `json:"driveFileType"` // DriveFileUpdatedAt 网盘文件修改时间,格式:2025-03-03 10:39:14 DriveFileUpdatedAt string `json:"driveFileUpdatedAt"` // DriveFileCreatedAt 网盘文件创建时间,格式:2025-03-03 10:39:14 DriveFileCreatedAt string `json:"driveFileCreatedAt"` }
type RemoveFilePrepareParams ¶ added in v0.3.7
type RemoveFilePrepareParams struct { Count int `json:"count"` Items []*RemoveFilePrepareItem `json:"items"` }
RemoveFilePrepareParams 删除文件前的回调函数-参数
type RemoveFilePrepareResult ¶ added in v0.3.7
type RemoveFilePrepareResult struct {
Result []*RemoveFilePrepareResultItem `json:"result"`
}
RemoveFilePrepareResult 删除文件前的回调函数-返回结果
type RemoveFilePrepareResultItem ¶ added in v0.3.7
type SyncAllFileFinishParams ¶ added in v0.3.7
type SyncAllFileFinishParams struct { // Name 任务名称 Name string `json:"name"` // Id 任务ID Id string `json:"id"` // UserId 账号ID UserId string `json:"userId"` // DriveName 网盘名称,backup-备份盘,resource-资源盘 DriveName string `json:"driveName"` // DriveId 网盘ID,目前支持文件网盘 DriveId string `json:"driveId"` // LocalFolderPath 本地目录 LocalFolderPath string `json:"localFolderPath"` // PanFolderPath 云盘目录 PanFolderPath string `json:"panFolderPath"` // Mode 备份模式 Mode string `json:"mode"` // Policy 备份策略 Policy string `json:"policy"` }
SyncAllFileFinishParams 同步备份-全部文件同步结束-回调参数
type SyncFileFinishParams ¶ added in v0.2.3
type SyncFileFinishParams struct { Action string `json:"action"` ActionResult string `json:"actionResult"` DriveId string `json:"driveId"` DriveFileId string `json:"driveFileId"` FileName string `json:"fileName"` FilePath string `json:"filePath"` FileSha1 string `json:"fileSha1"` FileSize int64 `json:"fileSize"` FileType string `json:"fileType"` FileUpdatedAt string `json:"fileUpdatedAt"` }
SyncFileFinishParams 同步备份-一个文件同步结束-回调参数
type SyncScanLocalFilePrepareParams ¶ added in v0.1.6
type SyncScanLocalFilePrepareParams struct { LocalFilePath string `json:"localFilePath"` LocalFileName string `json:"localFileName"` LocalFileSize int64 `json:"localFileSize"` LocalFileType string `json:"localFileType"` LocalFileUpdatedAt string `json:"localFileUpdatedAt"` DriveId string `json:"driveId"` }
SyncScanLocalFilePrepareParams 同步备份-扫描本地文件前参数
type SyncScanLocalFilePrepareResult ¶ added in v0.1.6
type SyncScanLocalFilePrepareResult struct { // SyncScanLocalApproved 该文件是否确认扫描,yes-允许扫描,no-禁止扫描 SyncScanLocalApproved string `json:"syncScanLocalApproved"` }
SyncScanLocalFilePrepareResult 同步备份-扫描本地文件-返回结果
type SyncScanPanFilePrepareParams ¶ added in v0.1.6
type SyncScanPanFilePrepareParams struct { DriveId string `json:"driveId"` DriveFileName string `json:"driveFileName"` DriveFilePath string `json:"driveFilePath"` DriveFileSha1 string `json:"driveFileSha1"` DriveFileSize int64 `json:"driveFileSize"` DriveFileType string `json:"driveFileType"` DriveFileUpdatedAt string `json:"driveFileUpdatedAt"` }
SyncScanPanFilePrepareParams 同步备份-扫描云盘文件前参数
type SyncScanPanFilePrepareResult ¶ added in v0.1.6
type SyncScanPanFilePrepareResult struct { // SyncScanPanApproved 该文件是否确认扫描,yes-允许扫描,no-禁止扫描 SyncScanPanApproved string `json:"syncScanPanApproved"` }
SyncScanPanFilePrepareResult 同步备份-扫描云盘文件-返回结果
type UploadFileFinishParams ¶
type UploadFileFinishParams struct { LocalFilePath string `json:"localFilePath"` LocalFileName string `json:"localFileName"` LocalFileSize int64 `json:"localFileSize"` LocalFileType string `json:"localFileType"` LocalFileUpdatedAt string `json:"localFileUpdatedAt"` LocalFileSha1 string `json:"localFileSha1"` UploadResult string `json:"uploadResult"` DriveId string `json:"driveId"` DriveFilePath string `json:"driveFilePath"` }
UploadFileFinishParams 上传文件结束的回调函数-参数
type UploadFilePrepareParams ¶
type UploadFilePrepareParams struct { LocalFilePath string `json:"localFilePath"` LocalFileName string `json:"localFileName"` LocalFileSize int64 `json:"localFileSize"` LocalFileType string `json:"localFileType"` LocalFileUpdatedAt string `json:"localFileUpdatedAt"` DriveId string `json:"driveId"` DriveFilePath string `json:"driveFilePath"` }
UploadFilePrepareParams 上传文件前的回调函数-参数
type UploadFilePrepareResult ¶
type UploadFilePrepareResult struct { // UploadApproved 确认该文件是否上传。yes-上传 no-不上传 UploadApproved string `json:"uploadApproved"` // DriveFilePath 保存网盘的修改后的路径。注意该路径是相对路径 DriveFilePath string `json:"driveFilePath"` }
UploadFilePrepareResult 上传文件前的回调函数-返回结果
type UserTokenRefreshFinishParams ¶ added in v0.2.4
type UserTokenRefreshFinishParams struct { Result string `json:"result"` Message string `json:"message"` OldToken string `json:"oldToken"` NewToken string `json:"newToken"` UpdatedAt string `json:"updatedAt"` }
UserTokenRefreshFinishParams 用户Token刷新完成后回调函数