api

package
v0.0.0-...-3509aed Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package api is the Filez CLI's HTTP client to a Filez server.

Index

Constants

This section is empty.

Variables

View Source
var ErrBucketGone = errors.New("closed or unknown")

ErrBucketGone means the sync bucket no longer exists (closed or expired).

View Source
var ErrLiveGone = errors.New("live session not found")

ErrLiveGone means the live session no longer exists on the server.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL   string
	AccessKey string
	HTTP      *http.Client
}

Client talks to one Filez server.

func FromHost

func FromHost(h *config.Host) *Client

FromHost builds a client from a configured host.

func New

func New(baseURL, accessKey string) *Client

New builds a client for a base URL and optional access key.

func (*Client) AuthCheck

func (c *Client) AuthCheck() (bool, error)

AuthCheck reports whether the client's access key is accepted (or the instance is public).

func (*Client) Info

func (c *Client) Info() (*Info, error)

Info fetches server metadata and verifies the host is a Filez instance.

func (*Client) LivePush

func (c *Client) LivePush(sessionID, path string) error

LivePush replaces the current frame of a live session with the given file. It returns ErrLiveGone if the session has ended server-side.

func (*Client) LiveStart

func (c *Client) LiveStart() (*LiveSession, error)

LiveStart creates a new live session on the server.

func (*Client) LiveStop

func (c *Client) LiveStop(sessionID string) error

LiveStop ends a live session on the server (idempotent).

func (*Client) SyncClose

func (c *Client) SyncClose(code, ownerToken string) error

SyncClose closes a sync bucket using its owner token.

func (*Client) SyncCreate

func (c *Client) SyncCreate() (*SyncBucket, error)

SyncCreate creates a new sync bucket on the server.

func (*Client) SyncDownload

func (c *Client) SyncDownload(code, fileID, dest string) (int64, error)

SyncDownload downloads one file from a bucket to dest.

func (*Client) SyncList

func (c *Client) SyncList(code string) ([]SyncFile, error)

SyncList returns the files currently in a bucket.

func (*Client) SyncUpload

func (c *Client) SyncUpload(code, path string) error

SyncUpload adds a file to a sync bucket (anyone with the code may do this).

func (*Client) Upload

func (c *Client) Upload(path string, opts UploadOptions, progress func(sent, total int64)) (*UploadResult, error)

Upload streams a file to the server, reporting progress (bytes of the file sent) via the optional callback.

type Info

type Info struct {
	Filez         bool   `json:"filez"`
	Version       string `json:"version"`
	Public        bool   `json:"public"`
	AdminEnabled  bool   `json:"admin_enabled"`
	DefaultUpload string `json:"default_upload"`
	MaxUploadSize int64  `json:"max_upload_size"`
}

Info is the /api/info response.

type LiveSession

type LiveSession struct {
	SessionID string `json:"session_id"`
	ViewerURL string `json:"viewer_url"`
}

LiveSession is the /api/live start response.

type SyncBucket

type SyncBucket struct {
	Code       string `json:"code"`
	OwnerToken string `json:"owner_token"`
	URL        string `json:"url"`
}

SyncBucket is the /api/sync create response.

type SyncFile

type SyncFile struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Size int64  `json:"size"`
	MIME string `json:"mime"`
}

SyncFile is one file listed in a bucket.

type UploadOptions

type UploadOptions struct {
	Mode      string // permanent | temp | limited
	TTL       string // for temp, e.g. "2d20m"
	Downloads int    // for limited
	Password  string // optional, any mode
	Keep      bool   // exempt from idle cleanup (needs permission on private)
}

UploadOptions describe an upload request.

type UploadResult

type UploadResult struct {
	ID         string `json:"id"`
	Ext        string `json:"ext"`
	URL        string `json:"url"`
	PreviewURL string `json:"preview_url"`
}

UploadResult is the /api/upload response.

Jump to

Keyboard shortcuts

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