filer

package module
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 2 modules, 2 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.

README

go-filer

Go Reference Test

Filer puts object-oriented data sources behind one file system.

  • Sources: local file systems, S3 buckets, Google Workspace (Drive, Calendar, Contacts and Tasks) and RSS feeds are each a volume of objects and folders.
  • Indexed: each volume is indexed, and its objects' metadata enriched, such as a photo's camera and place, a song's artist, or a document's title.
  • Search: search files, tasks, events, and media using rich metadata queries from the index.
  • Interfaces: a web application, a command line, and a REST API.

Quick Start

[!WARNING] Don't run filer on the internet. It has no authentication yet, so anyone who can reach it can read, and change, your volumes and credentials. Publish its port on localhost only, as below, or put it behind a proxy that signs people in, or a VPN.

Run the server, with a directory of yours mounted, such as /mnt/media, as a volume, media, whose files are indexed, and their metadata read:

docker volume create filer

docker run -d --name filer -p 127.0.0.1:8084:8084 \
  -v filer:/data -v /mnt/media:/media:ro \
  ghcr.io/mutablelogic/filer run --volume "file://media/media?index=metadata"

Then open http://localhost:8084/.

  • --volume: the URL of a volume, whose host is its name, and whose path is in the container, which is created, or updated, each time the server starts. It can be repeated.
  • Add Volume adds more, in the web UI, such as a Server filesystem of another directory which is mounted.

Choose a volume to browse its folders and files, and a file to see its metadata, preview it, play it, or download it:

A volume's folders and files, and a film's metadata, of its file and TMDB

  • Data: credentials and the index are kept in /data/filer, and volumes' caches in /data/cache.
  • User: the server runs as the filer user. Set UID and GID, such as to the owner of the mounted directories, which /data is made the owner of.
  • Docker Compose: docker/compose.yaml runs it with its variables, such as TMDB_TOKEN and ACOUSTID_KEY, which look up films and recordings, and FILER_TLS_NAME, behind a proxy which serves it over TLS: docker compose -f docker/compose.yaml up -d.
  • Image: ghcr.io/mutablelogic/filer, for linux/amd64 and linux/arm64, is published with each release, built with cgo, so it reads the metadata of audio, video and photos.

For the command line:

CGO_ENABLED=0 go install -tags client github.com/mutablelogic/go-filer/cmd/filer@latest
filer volume-create-fs media /media -o index=metadata
filer volumes
filer search beethoven

It talks to localhost:8084, or FILER_ADDR. Inside the container, docker exec filer filer volumes does the same.

Adding Google Workspace

Google Drive, Calendar, Contacts and Tasks are volumes too, which sign in with Google, as you, once you've an OAuth client of your own:

  1. Create a project in the Google Cloud console, and enable the APIs of the volumes you want: the Drive API, the Google Calendar API, the People API (Contacts) and the Google Tasks API.

  2. Set up the consent screen (Google Auth Platform), as an external app in testing, with yourself as a test user.

  3. Create an OAuth client, of the type Web application, whose authorized redirect URIs are:

    • http://localhost:8084/api/credential-signin/callback, of the web UI, or https://<host>/api/credential-signin/callback, as it's reached (Google only allows http of localhost);
    • http://localhost:8085/callback, of the command line.

    Download its JSON.

  4. Store it as the server's GOOGLE_CLIENT credential:

    docker exec -i filer filer credential-set GOOGLE_CLIENT --json < client_secret.json
    
  5. Add a volume, with Add Volume, such as Google Drive, and Sign in with Google, in the window which opens. Or, with the command line, filer volume-create-gdrive drive, which signs in, in the browser.

One sign-in, GOOGLE_TOKEN, is shared by the Google volumes, and asks for each one's access as it's added. See Google for each volume's layout, options and writing.

Architecture

flowchart LR
    ui[Web UI] --> api
    cli[Command line] --> api
    rest[REST API clients] --> api
    api[HTTP API] --> registry[Registry]
    registry --> volumes
    subgraph volumes[Volumes]
        fs[Filesystem]
        s3[S3]
        google[Google Workspace]
        rss[RSS feeds]
    end
    registry --> indexer[Indexer]
    indexer --> volumes
    indexer --> store[(Store: objects, metadata, search)]
    indexer --> enrich[Metadata task, of go-metadata]
    enrich --> volumes
    registry --> changes[Changes] --> ui
  • Backends: each source, of a URL's scheme, such as file, s3, gdrive or rss: its layout, options, writing and watching.
  • Architecture: the registry of volumes, the indexer and its store, metadata enrichment and search, the volumes' caches, actions, and watching changes.
  • Development: the Go packages, building with go-media's libraries, testing, using them as a library, the object model, and errors.
  • Web UI: the frontend, which the server embeds.

Roadmap

TODO: milestones of these themes, from the issue list:

  • File browser: upload and delete (#216), sorting (#218), more of a preview (#219), and its packages (#148, #149, #220).
  • Indexing: failed files (#217), artwork (#146) and content (#147).
  • Search: its UI (#150), filters, places and events (#138–#142), and saved searches (#151).
  • Backends: Gmail (#144), MCP servers (#145), Drive's moves (#174), and a Postgres store (#72).
  • Authentication, so it can be run beyond localhost.

License

go-filer is licensed under the Apache License, Version 2.0.

Third-party libraries

Built with cgo, as make and the Docker image are, the filer command links go-media's libraries, of the LGPL build of its release, which read the metadata of audio, video and photos. A build of CGO_ENABLED=0 has none of them. See go-media's NOTICE for their versions, copyrights and sources.

Library License
FFmpeg LGPL version 3 or later, of its LGPL build
libexif LGPL version 2.1 or later
libheif LGPL version 3
LibRaw LGPL version 2.1, or CDDL version 1.0
Chromaprint LGPL version 2.1, as a whole (its own code is MIT)
libfvad BSD 3-clause, with Google's patent grant

They're linked statically, so under the LGPL, the source of this program, and its Makefile, which links go-media's libraries, or a build of them of your own, of GO_MEDIA_PREFIX, let you relink it with a modified version of them.

The libraries they link with, in turn, are the system's, which the Docker image installs from Debian, each with its copyright in /usr/share/doc/<package>/copyright:

Library License
libde265 LGPL version 3
libaom BSD 2-clause, with the AOMedia patent license
dav1d BSD 2-clause
libxml2 MIT
OpenSSL Apache License 2.0
zstd BSD 3-clause, or GPL version 2
XZ Utils (liblzma) 0BSD
zlib zlib License
GCC's runtime (libstdc++, libgcc, libgomp) GPL version 3, with the GCC Runtime Library Exception
glibc LGPL version 2.1 or later

The web UI, which the server embeds, includes:

Package License
Carbon Design System: web components, charts, icons and styles Apache License 2.0
Lit BSD 3-clause
marked MIT
DOMPurify Apache License 2.0, or MPL 2.0
IBM Plex Sans and Mono SIL Open Font License 1.1
go-server's frontend Apache License 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActionOf added in v0.5.0

func ActionOf(action Action) schema.Action

ActionOf returns what an action is, without running it, as it's listed, such as over HTTP

func HTTPErr added in v0.1.2

func HTTPErr(err error) error

HTTPErr translates an error into an error wrapping a HTTP status code

func PatchValues added in v0.3.0

func PatchValues(values, patch url.Values) url.Values

PatchValues returns a copy of the options, changed by the patch: each key of the patch replaces the option's values with its own, or, when it has none, removes the option, so it's the default

func ValidActionName added in v0.5.0

func ValidActionName(name string) bool

ValidActionName returns true when the name of an action is valid: of letters, digits, "_" and "-", of up to 64 characters, as a tool's name is

Types

type Action added in v0.5.0

type Action interface {
	// Name is the action's identifier, in snake_case, such as create_event,
	// which is a tool's name as it is (see ValidActionName)
	Name() string

	// Title is a short label of the action, such as "Create event"
	Title() string

	// Description is what the action does, for people and models
	Description() string

	// Input is the JSON schema of the action's input
	Input() *jsonschema.Schema

	// Run does the action, with its input, which is JSON of its schema, and
	// returns the object it created or changed
	Run(ctx context.Context, input json.RawMessage) (*schema.Object, error)
}

Action is something a backend can do, beyond reading and writing its objects, such as creating a calendar event, which a Filer returns of Actions. It maps onto an LLM tool: its name, description and input are a tool's, and the object it returns is the tool's result.

type Err added in v0.1.2

type Err int

Errors

const (
	ErrSuccess Err = iota
	ErrNotFound
	ErrBadParameter
	ErrNotImplemented
	ErrConflict
	ErrInternalServerError
	ErrServiceUnavailable
	ErrForbidden
	ErrNotModified
	ErrCreated              // not a failure: the object was created, rather than replaced
	ErrPreconditionFailed   // a condition of the request isn't met, such as replacing an object which doesn't exist
	ErrUnprocessableContent // the request can't be processed, such as creating an object whose name is skipped
	ErrNotAuthorized        // the backend needs its user to sign in, such as to their Google account
)

func (Err) Error added in v0.1.2

func (e Err) Error() string

func (Err) HTTP added in v0.1.2

func (e Err) HTTP() httpresponse.Err

func (Err) With added in v0.1.2

func (e Err) With(args ...any) error

func (Err) Withf added in v0.1.2

func (e Err) Withf(format string, args ...any) error

Withf returns an error wrapping the error code, with a formatted message. As with fmt.Errorf, the format may use %w to wrap errors, so that they can still be matched with errors.Is and errors.As.

type Filer added in v0.3.0

type Filer interface {
	// URL returns the filer URL. The scheme, host (bucket/name),
	// and path (prefix/directory) identify the storage location. Query
	// parameters carry useful non-credential details: region, endpoint, anonymous, readonly, etc.
	URL() *url.URL

	// Description returns what the volume is, such as "Folder /mnt/media",
	// or "S3 bucket photos in eu-west-1", which is its URL's description
	// option, when it's set, and is otherwise the backend's of it
	Description() string

	// Actions returns what the backend can do, beyond reading and writing
	// its objects, such as creating a calendar event, or nil, such as for a
	// filesystem, whose objects are all it has
	Actions() []Action

	// Clone returns a new filer of the same storage, with the options of the
	// filer, changed by the patch (see PatchValues), which is nil to keep
	// them, from what the filer has, rather than its URL, which doesn't have
	// its credentials. The filer isn't changed, and the clone is checked as a
	// new filer is, such as a bucket being accessible. The registry clones a
	// volume's filer to change its options, and to open it again when
	// watching it fails.
	Clone(context.Context, url.Values) (Filer, error)

	// Create object in the filer, and return it, which is at the request's
	// path, unless the backend names it, such as a Google task, whose id
	// Google gives it
	CreateObject(context.Context, schema.CreateObjectRequest) (*schema.Object, error)

	// Get object metadata from the filer
	GetObject(context.Context, schema.GetObjectRequest) (*schema.Object, error)

	// Read object content from the filer, by calling the returned function,
	// with the object's metadata
	ReadObject(context.Context, schema.GetObjectRequest) (ReadObjectFunc, *schema.Object, error)

	// List objects in the filer. Call Next on the returned iterator until
	// io.EOF is returned. Caller must close the returned iterator.
	ListObjects(context.Context, schema.ListObjectsRequest) (schema.ListObjectsIterator, error)

	// Delete an object in the filer, and return the deleted object. A
	// directory is only deleted when the request is recursive, in which case
	// every object beneath it is deleted too. The root of a volume cannot be
	// deleted.
	DeleteObjects(context.Context, schema.DeleteObjectsRequest) (*schema.DeleteObjectsResponse, error)

	// Watch for changes to objects, sending each to the channel, until the
	// context is cancelled. The first is a rescan of the root, once the
	// objects are watched, so a caller which lists them then misses no
	// change. The channel isn't closed. It will return
	// filer.ErrNotImplemented if the filer backend does not support watching objects.
	WatchObjects(context.Context, chan<- schema.Event) error
}

Filer is the interface for storing files and objects. A filer which holds resources, such as a client, or a watch, also implements io.Closer, which its owner, such as the registry, calls, rather than those it's given to.

type Opts added in v0.3.0

type Opts struct {
	// Tracer traces the requests of the backend to other services, such as
	// S3, when it's set
	Tracer trace.Tracer

	// Credentials are the server's, which a backend looks up of the names in
	// its URL, such as S3_SECRET, or are its sign-in, such as Google's, when
	// it's set
	Credentials credential.CredentialProvider

	// ClientOpts are the options of the clients of a backend which calls
	// other services over HTTP, such as Google's, which it's given as they
	// are, such as a user agent, a tracer, of client.OptTracer, a trace, or
	// a timeout
	ClientOpts []client.ClientOpt
}

Opts are the options of a backend, which the registry passes to it when it's created

type ReadObjectFunc added in v0.3.0

type ReadObjectFunc func(context.Context, func(io.Reader) error) error

ReadObjectFunc reads an object's content: it opens the object, calls the function with a reader of the content, and closes the object when the function returns. The reader returns an error once the context is cancelled, or the filer is closed. Returns the function's error, or the error opening or closing the object.

Directories

Path Synopsis
backend
fs
Package fs provides the filesystem interface for managing objects in directories.
Package fs provides the filesystem interface for managing objects in directories.
fs/fsevents
Package fsevents watches a directory, and everything beneath it, for files and directories which are created, updated and deleted, using the efficient mechanism of each platform: FSEvents on macOS, ReadDirectoryChangesW on Windows, and inotify on Linux.
Package fsevents watches a directory, and everything beneath it, for files and directories which are created, updated and deleted, using the efficient mechanism of each platform: FSEvents on macOS, ReadDirectoryChangesW on Windows, and inotify on Linux.
google
Package google has filers of Google's services, such as Tasks, whose requests are with the clients of package httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed.
Package google has filers of Google's services, such as Tasks, whose requests are with the clients of package httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed.
google/httpclient
Package httpclient has clients of Google's APIs, with go-auth's auth/httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed.
Package httpclient has clients of Google's APIs, with go-auth's auth/httpclient, so a request which isn't authorized returns an AuthError, which says a sign-in is needed.
internal/blocks
Package blocks reads a file at offsets, of the blocks of it which are requested, the last of which are kept, so a parser's reads, which are scattered across a file, such as a PDF's objects, are of few requests
Package blocks reads a file at offsets, of the blocks of it which are requested, the last of which are kept, so a parser's reads, which are scattered across a file, such as a PDF's objects, are of few requests
rss
Package rss is a backend of an RSS feed, of rss://<name>/<host>/<path>, whose items are files, of their days, /YYYY/YYYY-MM/DD-<title>.html, each an HTML page of the item, with its title, author, date and link as its metadata, and its enclosure, such as a podcast's episode, too.
Package rss is a backend of an RSS feed, of rss://<name>/<host>/<path>, whose items are files, of their days, /YYYY/YYYY-MM/DD-<title>.html, each an HTML page of the item, with its title, author, date and link as its metadata, and its enclosure, such as a podcast's episode, too.
s3
Package s3 is a filer of the objects in an S3 bucket, or one which is compatible, beneath a prefix
Package s3 is a filer of the objects in an S3 bucket, or one which is compatible, beneath a prefix
s3/seaweedfs
Package seaweedfs watches the changes to the objects of an S3 bucket of a SeaweedFS filer, by subscribing to the changes to the filer's metadata, with its gRPC service
Package seaweedfs watches the changes to the objects of an S3 bucket of a SeaweedFS filer, by subscribing to the changes to the filer's metadata, with its gRPC service
cmd
filer command
Package frontend is go-filer's web UI: its modules, such as Files, which the package @mutablelogic/go-filer exports, and the server's app, which make builds into app/dist, and which a command built with the "frontend" tag embeds, as EmbedFS.
Package frontend is go-filer's web UI: its modules, such as Files, which the package @mutablelogic/go-filer exports, and the server's app, which make builds into app/dist, and which a command built with the "frontend" tag embeds, as EmbedFS.
cmd
Package cmd serves the web UI, and the server's configuration, which it reads, beside the API, when the server is built with the "frontend" tag, which embeds the UI, once it's built, with npm, into frontend/app/dist, which make does.
Package cmd serves the web UI, and the server's configuration, which it reads, beside the API, when the server is built with the "frontend" tag, which embeds the UI, once it's built, with npm, into frontend/app/dist, which make does.
Package indexer is a filer which wraps another, and keeps an index of its folders, in a Store, which it follows the backend's changes in, so its folder tree is listed from the index, rather than the backend, which can be slow, such as a bucket, or a network mount.
Package indexer is a filer which wraps another, and keeps an index of its folders, in a Store, which it follows the backend's changes in, so its folder tree is listed from the index, rather than the backend, which can be slow, such as a bucket, or a network mount.
Package metadata is the task which enriches the files of a volume which is indexed with index=metadata, with their metadata, of go-metadata: tags of audio and video, EXIF of photos, the titles of documents, movies and TV episodes on TMDB, recordings on AcoustID, and so on.
Package metadata is the task which enriches the files of a volume which is indexed with index=metadata, with their metadata, of go-metadata: tags of audio and video, EXIF of photos, the titles of documents, movies and TV episodes on TMDB, recordings on AcoustID, and so on.
cmd
Package cmd is the flags of the metadata enrichment of a server, which it embeds, and composes into the registry of its volumes
Package cmd is the flags of the metadata enrichment of a server, which it embeds, and composes into the registry of its volumes
cmd
Package schema is the types of the objects in a backend, which are the types of the filer's objects
Package schema is the types of the objects in a backend, which are the types of the filer's objects
pg
Package pg is an index store in a Postgres database, which isn't implemented yet (#72): each of its methods returns ErrNotImplemented
Package pg is an index store in a Postgres database, which isn't implemented yet (#72): each of its methods returns ErrNotImplemented
sqlite
Package sqlite is a store of volumes, and their indexes, in a SQLite database, which is created when it doesn't exist, or in memory, of sqlite.Memory, such as for tests
Package sqlite is a store of volumes, and their indexes, in a SQLite database, which is created when it doesn't exist, or in memory, of sqlite.Memory, such as for tests
sqlite/schema
Package schema is the schema of the SQLite store: its tables, its queries, and the types which are read from, and written to, them
Package schema is the schema of the SQLite store: its tables, its queries, and the types which are read from, and written to, them
test
Package test is the conformance tests of an index store, which each store runs, so they behave the same
Package test is the conformance tests of an index store, which each store runs, so they behave the same

Jump to

Keyboard shortcuts

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