filebrowse

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

templ: version: v0.3.1001

Package filebrowse is the shared file browser: one fragment UI and one set of route bodies over any store that can list/read/write/delete by path. Backends today: docker volumes (db data volumes, service volume tiles) and s3 buckets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Browse

func Browse(c echo.Context, fs Backend, base string) error

Browse renders the listing fragment for ?path=.

func Browser

func Browser(c echo.Context, base, dir string, entries []Entry, canWrite bool) templ.Component

Browser is the listing fragment. base is the files route it re-fetches itself from; every navigation swaps the whole fragment in place.

func CleanDir

func CleanDir(p string) string

CleanDir confines a user-supplied dir to a /-rooted path with no "..".

func Delete

func Delete(c echo.Context, fs Backend, base string) error

Delete removes form value "target" (dir flag in "dir"), then re-renders the listing at "path".

func Download

func Download(c echo.Context, fs Backend) error

Download streams ?path= as an attachment.

func ErrorFrag

func ErrorFrag(base, msg string) templ.Component

ErrorFrag keeps the fragment (and a way back) when a backend op fails.

func Loader

func Loader(base string) templ.Component

Loader lazy-loads the browser when its tab opens.

func Upload

func Upload(c echo.Context, fs Backend, base string) error

Upload stores the posted file into the dir in form value "path", then re-renders the listing there.

Types

type Backend

type Backend interface {
	List(ctx context.Context, dir string) ([]Entry, error)
	Read(ctx context.Context, file string) (io.ReadCloser, error)
	Write(ctx context.Context, file string, src io.Reader) error
	Delete(ctx context.Context, p string, dir bool) error
}

Backend is what a store must speak for the shared handlers/templ.

type Entry

type Entry struct {
	Name    string
	Dir     bool
	Size    int64
	ModTime time.Time
}

Entry is one row of a listing.

type VolumeFS

type VolumeFS struct {
	Cluster *cluster.Cluster
	Node    string
	Vol     string
}

VolumeFS browses a docker volume via the throwaway-container ops, on whichever node holds it.

Node is the tile's home node and is the whole multi-node story here: a volume is a directory on one machine's disk, so browsing one on the manager while the tile runs on a worker shows the manager's copy, the wrong files, with no error to say so. Empty means "here", which is every single-node install.

func (VolumeFS) Delete

func (v VolumeFS) Delete(ctx context.Context, p string, dir bool) error

func (VolumeFS) List

func (v VolumeFS) List(ctx context.Context, dir string) ([]Entry, error)

func (VolumeFS) Read

func (v VolumeFS) Read(ctx context.Context, file string) (io.ReadCloser, error)

func (VolumeFS) Write

func (v VolumeFS) Write(ctx context.Context, file string, src io.Reader) error

Jump to

Keyboard shortcuts

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