storage

package
v0.6.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 27 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storage 实现存储挂载与文件管理:登记本地目录、远程 WebDAV 或 SMB 共享作为挂载点, 并提供浏览器内的文件浏览、上传、下载、新建目录、重命名与删除。

Index

Constants

View Source
const (
	TypeLocal  = "local"
	TypeWebDAV = "webdav"
	TypeSMB    = "smb"
)

挂载类型。

View Source
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 New

func New() *Module

New 创建模块。

func (*Module) ID

func (m *Module) ID() string

ID 实现 module.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) Init

func (m *Module) Init(env module.Env) error

Init 实现 module.Module。

func (*Module) ListNames

func (m *Module) ListNames(mount, dir string) ([]string, error)

ListNames 返回挂载点 dir 目录下的文件名(不含子目录)。目录不存在时返回空列表。

func (*Module) MountList

func (m *Module) MountList() []MountInfo

MountList 返回全部挂载点。

func (*Module) MountPath added in v0.4.0

func (m *Module) MountPath(key string) (string, bool)

MountPath 返回本地挂载点的目录,供导入 Lucky FTP / WebDAV 用户时解析存储引用。

func (*Module) PutFile

func (m *Module) PutFile(mount, dir, name string, data []byte) error

PutFile 把 data 写入挂载点 dir 目录下的 name 文件,目录不存在时逐级创建。

func (*Module) RemoveFile

func (m *Module) RemoveFile(mount, p string) error

RemoveFile 删除挂载点内的文件。

func (*Module) Routes

func (m *Module) Routes(r module.Router)

Routes 实现 module.Module。

func (*Module) Start

func (m *Module) Start(context.Context) error

Start 实现 module.Module,存储模块没有常驻服务。

func (*Module) Stop

func (m *Module) Stop() error

Stop 实现 module.Module。

func (*Module) Summary

func (m *Module) Summary() []module.SummaryItem

Summary 实现 module.Summarizer。

func (*Module) Title

func (m *Module) Title() string

Title 实现 module.Module。

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 是一个存储挂载点。

func (*Mount) Validate

func (mt *Mount) Validate() error

Validate 校验并规范化挂载点。

type MountInfo

type MountInfo struct {
	Key      string `json:"key"`
	Name     string `json:"name"`
	Type     string `json:"type"`
	Enable   bool   `json:"enable"`
	ReadOnly bool   `json:"readOnly"`
}

MountInfo 是供其他模块(如备份)选择挂载点的简要信息。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL