web

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamingUploadHandler added in v1.0.6

func StreamingUploadHandler(h *Handler) http.HandlerFunc

StreamingUploadHandler 使用原生 net/http 实现流式上传 绕过 Gin 的 multipart 解析,实现真正的边接收边写入

func UploadHandler added in v1.0.6

func UploadHandler(h *Handler) http.HandlerFunc

UploadHandler 处理 WebSocket 文件上传

Types

type ArchiveReq

type ArchiveReq struct {
	Name  string `json:"name"`
	Path  string `json:"path"`
	Items []Item `json:"items"`
}

type DeleteReq added in v1.0.6

type DeleteReq struct {
	Items []Item `json:"items"`
	Path  string `json:"path"`
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler() *Handler

func NewHandlerWithConfig added in v1.1.0

func NewHandlerWithConfig() *Handler

func (*Handler) Archive

func (h *Handler) Archive(ctx *gin.Context, req ArchiveReq) (ginx.Result, error)

func (*Handler) Delete added in v1.0.6

func (h *Handler) Delete(ctx *gin.Context, req DeleteReq) (ginx.Result, error)

func (*Handler) DownloadStream added in v1.0.8

func (h *Handler) DownloadStream(ctx *gin.Context)

DownloadStream 使用 http.ServeContent 实现流式下载,自动支持 Range/206

func (*Handler) Index

func (h *Handler) Index(ctx *gin.Context) (ginx.Result, error)

func (*Handler) Move

func (h *Handler) Move(ctx *gin.Context, req MoveReq) (ginx.Result, error)

func (*Handler) NewFile

func (h *Handler) NewFile(ctx *gin.Context, req NewFileReq) (ginx.Result, error)

func (*Handler) NewFolder

func (h *Handler) NewFolder(ctx *gin.Context, req NewFolderReq) (ginx.Result, error)

func (*Handler) Preview

func (h *Handler) Preview(ctx *gin.Context) (ginx.Result, error)

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(server *gin.Engine)

func (*Handler) RegisterUploadRoute added in v1.0.6

func (h *Handler) RegisterUploadRoute(server *gin.Engine)

RegisterUploadRoute 单独注册上传路由,在中间件之前 使用流式上传以支持实时进度显示

func (*Handler) Rename

func (h *Handler) Rename(ctx *gin.Context, req RenameReq) (ginx.Result, error)

func (*Handler) Save

func (h *Handler) Save(ctx *gin.Context, req SaveReq) (ginx.Result, error)

func (*Handler) Search

func (h *Handler) Search(ctx *gin.Context) (ginx.Result, error)

func (*Handler) SetFinder added in v1.0.1

func (h *Handler) SetFinder(id int64, f provider.CapabilityProvider)

func (*Handler) Unarchive added in v1.0.6

func (h *Handler) Unarchive(ctx *gin.Context, req UnarchiveReq) (ginx.Result, error)

func (*Handler) Upload

func (h *Handler) Upload(ctx *gin.Context) (ginx.Result, error)

type Item

type Item struct {
	Path string          `json:"path"`
	Type finder.FileType `json:"type"`
}

type MoveReq

type MoveReq struct {
	Path        string   `json:"path"`
	Item        string   `json:"item"`        // 目标路径(destination)
	Items       []Item   `json:"items"`       // 源文件列表(sources)
	Destination string   `json:"destination"` // 目标路径(前端可能使用这个字段)
	Sources     []string `json:"sources"`     // 源文件列表(前端发送的是字符串数组)
}

type NewFileReq

type NewFileReq struct {
	Path string `bson:"path"`
	Name string `json:"name"`
}

type NewFolderReq

type NewFolderReq struct {
	Path string `json:"path"`
	Name string `json:"name"`
}

type RenameReq

type RenameReq struct {
	Path string `json:"path"`
	Item string `json:"item"`
	Name string `json:"name"`
}

type RetrieveFolder

type RetrieveFolder struct {
	Folders []finder.FileInfo `json:"folders"`
}

type SaveReq

type SaveReq struct {
	Path    string `json:"path"`
	Content string `json:"content"`
}

type UnarchiveReq added in v1.0.6

type UnarchiveReq struct {
	Item string `json:"item"` // 要解压的文件路径
	Path string `json:"path"` // 解压到的目标目录
}

type UploadMessage added in v1.0.6

type UploadMessage struct {
	Type              string          `json:"type"`              // 消息类型
	ID                string          `json:"id"`                // 上传任务 ID
	FileName          string          `json:"fileName"`          // 文件名
	Path              string          `json:"path"`              // 目标路径
	Data              json.RawMessage `json:"data"`              // 数据(base64 编码的文件块或元数据)
	Size              int64           `json:"size"`              // 文件总大小
	Offset            int64           `json:"offset"`            // 当前偏移量(已接收的字节数)
	SFTPWritten       int64           `json:"sftpWritten"`       // 已写入 SFTP 的字节数(实时进度)
	Error             string          `json:"error"`             // 错误信息
	SFTPWriteStart    int64           `json:"sftpWriteStart"`    // SFTP 写入开始时间(Unix 毫秒时间戳)
	SFTPWriteEnd      int64           `json:"sftpWriteEnd"`      // SFTP 写入结束时间(Unix 毫秒时间戳)
	SFTPWriteDuration int64           `json:"sftpWriteDuration"` // SFTP 写入耗时(毫秒)
	FinalName         string          `json:"finalName"`
}

UploadMessage WebSocket 消息结构

type UploadReq added in v1.0.6

type UploadReq struct {
	Name string       `json:"name"`
	Type string       `json:"type"`
	Path string       `json:"path"`
	File bytes.Buffer `json:"file"`
}

type UploadSession added in v1.0.6

type UploadSession struct {
	ID       string
	FileName string
	Path     string
	Size     int64
	Sess     provider.UploadSession
	Finder   provider.CapabilityProvider
	Offset   int64
	// contains filtered or unexported fields
}

UploadSession 上传会话

Jump to

Keyboard shortcuts

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