Documentation
¶
Overview ¶
Package filesystem contains shared manifest and route helpers for file browser plugins backed by different remote filesystem protocols.
Index ¶
- func DetectMIME(p string, buf []byte) string
- func FilesTab(prefix string, opts ...FilesOption) plugin.Panel
- func IsText(mimeType string, buf []byte) bool
- func MimeFor(p string) string
- func Routes(prefix, protocol string) []plugin.Route
- func SniffStream(r io.ReadCloser) (string, io.ReadCloser)
- func Streams(_ string) []plugin.Stream
- type Chmodder
- type Client
- type Copier
- type DirPager
- type ErrorMapper
- type FileContent
- type FileEntry
- type FilePage
- type FilesOption
- type RangeOpener
- type Seekable
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectMIME ¶ added in v0.1.1
DetectMIME resolves a preview MIME, preferring the extension type and sniffing leading bytes when it's unknown. Never returns "" (unknown → octet-stream).
func IsText ¶ added in v0.1.1
IsText reports whether a preview buffer should be served as editable text.
func MimeFor ¶ added in v0.1.1
MimeFor returns the MIME type for a path by file extension, or "" if unknown.
func SniffStream ¶ added in v0.1.1
func SniffStream(r io.ReadCloser) (string, io.ReadCloser)
SniffStream is the streaming counterpart to DetectMIME: it peeks a stream's leading bytes for the MIME and returns a reader that replays them so the body streams whole. Never returns "".
Types ¶
type Client ¶
type Client interface {
Home(ctx context.Context) (string, error)
ReadDir(ctx context.Context, p string) ([]os.FileInfo, error)
Stat(ctx context.Context, p string) (os.FileInfo, error)
Open(ctx context.Context, p string) (io.ReadCloser, error)
Write(ctx context.Context, p string, r io.Reader) error
Mkdir(ctx context.Context, p string) error
Rename(ctx context.Context, from, to string) error
Remove(ctx context.Context, p string, isDir bool) error
}
type DirPager ¶ added in v0.1.1
type DirPager interface {
ReadDirPage(ctx context.Context, p string, cursor string, limit int) ([]os.FileInfo, string, error)
}
DirPager is an optional Client capability for backends whose listings are natively cursor-paged and potentially unbounded (object stores). Implementing it makes the browser fetch one bounded page at a time instead of draining a directory through ReadDir. The returned cursor is opaque and empty when the listing is exhausted; entries are ordered within a page only.
type ErrorMapper ¶
type FileContent ¶
type FilePage ¶
type FilePage struct {
Items []FileEntry `json:"items"`
NextCursor string `json:"nextCursor"`
Total *int `json:"total,omitempty"`
Path string `json:"path"`
Truncated bool `json:"truncated,omitempty"`
}
FilePage is one slice of a directory listing. Total is omitted for backends paged by DirPager, where the directory size is unknown without draining it; Truncated then tells the browser more entries remain behind NextCursor.
type FilesOption ¶
type FilesOption func(*plugin.FileBrowserConfig)
FilesOption opts a FilesTab into optional filesystem operations a backend supports.
func WithArchive ¶
func WithArchive(prefix string) FilesOption
func WithChmod ¶
func WithChmod(prefix string) FilesOption
func WithCopy ¶
func WithCopy(prefix string) FilesOption
func WithMove ¶
func WithMove(prefix string) FilesOption
type RangeOpener ¶
type RangeOpener interface {
OpenRange(ctx context.Context, p string, offset, length int64) (io.ReadCloser, error)
}
RangeOpener is an optional Client capability for backends that read from an offset but cannot seek. length <= 0 means to EOF.