Documentation
¶
Overview ¶
Package storage 实现存储挂载与文件管理:登记本地目录、远程 WebDAV 或 SMB 共享作为挂载点, 并提供浏览器内的文件浏览、上传、下载、新建目录、重命名与删除。
Index ¶
- Constants
- type Entry
- type Module
- func (m *Module) ID() string
- func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
- func (m *Module) Init(env module.Env) error
- func (m *Module) ListNames(mount, dir string) ([]string, error)
- func (m *Module) MountList() []MountInfo
- func (m *Module) MountPath(key string) (string, bool)
- func (m *Module) PutFile(mount, dir, name string, data []byte) error
- func (m *Module) RemoveFile(mount, p string) error
- func (m *Module) Routes(r module.Router)
- func (m *Module) Start(context.Context) error
- func (m *Module) Stop() error
- func (m *Module) Summary() []module.SummaryItem
- func (m *Module) Title() string
- type Mount
- type MountInfo
Constants ¶
const ( TypeLocal = "local" TypeWebDAV = "webdav" TypeSMB = "smb" )
挂载类型。
const ID = "storage"
ID 是模块标识。
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"name"`
IsDir bool `json:"isDir"`
Size int64 `json:"size"`
ModTime time.Time `json:"modTime"`
}
Entry 是目录列表中的一项。
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module 是存储模块。
func (*Module) ImportLucky ¶ added in v0.4.0
func (m *Module) ImportLucky(doc luckyimport.Document, opts luckyimport.Options) (*luckyimport.Report, error)
ImportLucky 实现 luckyimport.Importer,迁移 Lucky 存储管理中的本地目录与 WebDAV 存储。 沿用 Lucky 的存储 Key,FTP / WebDAV 用户引用的存储在之后单独导入时仍能解析。
func (*Module) RemoveFile ¶
RemoveFile 删除挂载点内的文件。
func (*Module) Summary ¶
func (m *Module) Summary() []module.SummaryItem
Summary 实现 module.Summarizer。
type Mount ¶
type Mount struct {
Key string `json:"key"`
Name string `json:"name"`
// Group 为列表中的分组名称,只影响管理界面的展示,留空为未分组
Group string `json:"group"`
Type string `json:"type"`
Remark string `json:"remark"`
Enable bool `json:"enable"`
// ReadOnly 为 true 时文件管理拒绝一切写操作
ReadOnly bool `json:"readOnly"`
// Path 是本地目录(绝对路径),Type 为 local 时使用
Path string `json:"path"`
// 以下字段在 Type 为 webdav 或 smb 时使用;smb 的 URL 形如 smb://主机[:端口]/共享名[/子目录]
URL string `json:"url"`
Username string `json:"username"`
Password string `json:"password"`
// SkipVerify 仅 webdav 使用
SkipVerify bool `json:"skipVerify"`
// Domain 是 SMB 认证所用的域或工作组,仅 smb 使用,通常留空
Domain string `json:"domain,omitempty"`
}
Mount 是一个存储挂载点。