client

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package client provides FileBrowser API clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClient

type AuthClient struct {
	C *httpclient.Client
}

AuthClient handles authentication operations.

func (*AuthClient) Login

func (a *AuthClient) Login(ctx context.Context, username, password string) (string, error)

Login authenticates with FileBrowser and returns the token. The token is also stored on a.C.Token for subsequent requests.

func (*AuthClient) Renew

func (a *AuthClient) Renew(ctx context.Context) (string, error)

Renew refreshes the current token. Requires a valid token to be set.

func (*AuthClient) Whoami

func (a *AuthClient) Whoami(ctx context.Context) (string, error)

Whoami returns the current username. FileBrowser doesn't have a dedicated endpoint, so we parse the JWT token.

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

LoginRequest is the request body for login.

type Resource

type Resource struct {
	Path      string     `json:"path"`
	Name      string     `json:"name"`
	IsDir     bool       `json:"isDir"`
	Size      int64      `json:"size"`
	Modified  string     `json:"modified"`
	Created   string     `json:"created"`
	Type      string     `json:"type"`
	Extension string     `json:"extension"`
	Items     []Resource `json:"items"`
	NumDirs   int        `json:"numDirs"`
	NumFiles  int        `json:"numFiles"`
	Content   string     `json:"content,omitempty"`
	Checksum  string     `json:"checksum,omitempty"`
}

Resource represents a FileBrowser file or directory.

type ResourceClient

type ResourceClient struct {
	C *httpclient.Client
}

ResourceClient handles resource operations.

func (*ResourceClient) Copy

func (r *ResourceClient) Copy(ctx context.Context, src, dst string) error

Copy copies a resource.

func (*ResourceClient) Download

func (r *ResourceClient) Download(ctx context.Context, remotePath, localPath string) error

Download downloads a remote file to a local path.

func (*ResourceClient) Info

func (r *ResourceClient) Info(ctx context.Context, path string) (*Resource, error)

Info returns detailed information about a resource.

func (*ResourceClient) List

func (r *ResourceClient) List(ctx context.Context, path string) (*Resource, error)

List returns the contents of a directory.

func (*ResourceClient) Mkdir

func (r *ResourceClient) Mkdir(ctx context.Context, path string) error

Mkdir creates a directory at the remote path.

func (*ResourceClient) Move

func (r *ResourceClient) Move(ctx context.Context, src, dst string) error

Move moves or renames a resource.

func (*ResourceClient) Preview

func (r *ResourceClient) Preview(ctx context.Context, path, size string) ([]byte, error)

Preview returns an image preview of a resource. size must be "thumb" (256x256) or "big" (1080x1080).

func (*ResourceClient) Remove

func (r *ResourceClient) Remove(ctx context.Context, path string) error

Remove deletes a resource at the remote path.

func (*ResourceClient) Upload

func (r *ResourceClient) Upload(ctx context.Context, localPath, remotePath string, override bool) error

Upload uploads a local file to the remote path.

type SearchClient

type SearchClient struct {
	C *httpclient.Client
}

SearchClient handles search operations.

func (*SearchClient) Search

func (s *SearchClient) Search(ctx context.Context, path, query string, limit int) ([]SearchResult, error)

Search searches for files matching the query. path is the directory to search in, query is the search term. limit is the maximum number of results (0 = no limit).

type SearchResult

type SearchResult struct {
	Dir  bool   `json:"dir"`
	Path string `json:"path"`
}

SearchResult represents a single search result.

type Share

type Share struct {
	Hash     string `json:"hash"`
	Path     string `json:"path"`
	Expire   int64  `json:"expire"`
	UserID   int    `json:"userID"`
	Username string `json:"username"`
	Token    string `json:"token,omitempty"`
}

Share represents a FileBrowser share.

type ShareClient

type ShareClient struct {
	C *httpclient.Client
}

ShareClient handles share operations.

func (*ShareClient) Create

func (s *ShareClient) Create(ctx context.Context, path, expires, unit, password string) (*Share, error)

Create creates a new share for the given path.

func (*ShareClient) Delete

func (s *ShareClient) Delete(ctx context.Context, hash string) error

Delete removes a share by hash.

func (*ShareClient) Info

func (s *ShareClient) Info(ctx context.Context, path string) ([]Share, error)

Info returns shares for a specific path.

func (*ShareClient) List

func (s *ShareClient) List(ctx context.Context) ([]Share, error)

List returns all shares.

type User

type User struct {
	ID       int      `json:"id"`
	Username string   `json:"username"`
	Password string   `json:"password,omitempty"`
	Scopes   []string `json:"scopes,omitempty"`
}

User represents a FileBrowser user.

Jump to

Keyboard shortcuts

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