storage

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 26 Imported by: 0 modules, 0 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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath = errors.New("invalid storage path")
	ErrNotFound    = errors.New("storage file not found")
)

Functions

func DocumentText added in v0.2.4

func DocumentText(name string, mimeType string, data []byte) (string, string, error)

DocumentText is the text of a stored file, with what it was read as: plain text in UTF-8, UTF-16 or Windows-1251, a PDF, an office document or the listing of an archive.

func NewDeleteTool

func NewDeleteTool(store deleteStore) tools.Executor

func NewListTool

func NewListTool(store listStore) tools.Executor

func NewReadTool

func NewReadTool(store readStore) tools.Executor

func NewSaveTemporaryTool

func NewSaveTemporaryTool(store saveTemporaryStore) tools.Executor

func NewSaveTool

func NewSaveTool(store saveStore) tools.Executor

func NewUpdateMetadataTool

func NewUpdateMetadataTool(store updateMetadataStore) tools.Executor

Types

type CleanupResponse

type CleanupResponse struct {
	Cleanup CleanupResult `json:"cleanup"`
}

type CleanupResult

type CleanupResult struct {
	DeletedFiles int   `json:"deleted_files"`
	FreedBytes   int64 `json:"freed_bytes"`
}

type Config

type Config struct {
	Root     string
	MaxBytes int64
}

type Entry

type Entry struct {
	Path      string    `json:"path"`
	Title     string    `json:"title,omitempty"`
	Tags      []string  `json:"tags,omitempty"`
	MIMEType  string    `json:"mime_type,omitempty"`
	Size      int64     `json:"size"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type FileResponse

type FileResponse struct {
	File Entry `json:"file"`
}

type FileSaveRequest

type FileSaveRequest struct {
	Path          string   `json:"path"`
	ContentBase64 string   `json:"content_base64"`
	Title         string   `json:"title"`
	Tags          []string `json:"tags"`
	MIMEType      string   `json:"mime_type"`
}

func NewFileSaveRequest

func NewFileSaveRequest(path string, content []byte, title string, tags []string, mimeType string) FileSaveRequest

func (FileSaveRequest) ContentBytes

func (r FileSaveRequest) ContentBytes() ([]byte, error)

func (*FileSaveRequest) UnmarshalJSON

func (r *FileSaveRequest) UnmarshalJSON(data []byte) error

type ListFilter

type ListFilter struct {
	Prefix string
	Query  string
	Limit  int
}

type ListResult

type ListResult struct {
	Root  string  `json:"root"`
	Files []Entry `json:"files"`
}

type LocalStore

type LocalStore struct {
	// contains filtered or unexported fields
}

func NewLocalStore

func NewLocalStore(root string, maxBytes int64) (*LocalStore, error)

func (*LocalStore) CleanupTemporary

func (s *LocalStore) CleanupTemporary() (CleanupResult, error)

func (*LocalStore) CopyTemporary

func (s *LocalStore) CopyTemporary(rawPath string, destPath string) (Entry, error)

func (*LocalStore) Delete

func (s *LocalStore) Delete(rawPath string) (Entry, error)

func (*LocalStore) DeleteTemporary

func (s *LocalStore) DeleteTemporary(rawPath string) (TempEntry, error)

func (*LocalStore) List

func (s *LocalStore) List(prefix string, query string, limit int) ([]Entry, error)

func (*LocalStore) ListTemporary

func (s *LocalStore) ListTemporary(limit int) (TempListResult, error)

func (*LocalStore) LocalPath added in v0.2.4

func (s *LocalStore) LocalPath(rawPath string, temporary bool) string

LocalPath is where a stored file lies on disk, for tools that take a file path; it is empty for a path storage would refuse.

func (*LocalStore) PromoteTemporary

func (s *LocalStore) PromoteTemporary(rawPath string, destPath string) (Entry, error)

func (*LocalStore) Read

func (s *LocalStore) Read(rawPath string, maxBytes int64) (Entry, string, error)

func (*LocalStore) ReadBytes

func (s *LocalStore) ReadBytes(rawPath string, maxBytes int64) (Entry, []byte, error)

func (*LocalStore) ReadTemporaryBytes

func (s *LocalStore) ReadTemporaryBytes(rawPath string) (TempEntry, []byte, error)

func (*LocalStore) Root

func (s *LocalStore) Root() string

func (*LocalStore) Save

func (s *LocalStore) Save(rawPath string, content string, title string, tags []string, mimeType string) (Entry, error)

func (*LocalStore) SaveBytes

func (s *LocalStore) SaveBytes(rawPath string, content []byte, title string, tags []string, mimeType string) (Entry, error)

func (*LocalStore) SaveTemporary

func (s *LocalStore) SaveTemporary(rawPath string, content []byte, title string, tags []string, mimeType string) (TempEntry, error)

func (*LocalStore) UpdateMetadata

func (s *LocalStore) UpdateMetadata(rawPath string, title string, tags []string, mimeType string) (Entry, error)

func (*LocalStore) UpdateTemporarySettings

func (s *LocalStore) UpdateTemporarySettings(autoCleanup *bool, ttlDays int64, maxGB float64) (TempSettings, error)

type Module

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Module, error)

func (*Module) Store

func (m *Module) Store() *LocalStore

func (*Module) Tools added in v0.2.0

func (m *Module) Tools() []tools.Executor

Tools are the storage tools.

type ReadBytesResponse added in v0.1.15

type ReadBytesResponse struct {
	File          Entry  `json:"file"`
	ContentBase64 string `json:"content_base64"`
}

func NewReadBytesResponse added in v0.1.15

func NewReadBytesResponse(file Entry, content []byte) ReadBytesResponse

func (ReadBytesResponse) ContentBytes added in v0.1.15

func (r ReadBytesResponse) ContentBytes() ([]byte, error)

type ReadResult

type ReadResult struct {
	File    Entry  `json:"file"`
	Content string `json:"content"`
}

type TempEntry

type TempEntry struct {
	Path      string    `json:"path"`
	Title     string    `json:"title,omitempty"`
	Tags      []string  `json:"tags,omitempty"`
	MIMEType  string    `json:"mime_type,omitempty"`
	Size      int64     `json:"size"`
	CreatedAt time.Time `json:"created_at"`
	ExpiresAt time.Time `json:"expires_at"`
}

type TempFileResponse

type TempFileResponse struct {
	File TempEntry `json:"file"`
}

type TempListResult

type TempListResult struct {
	Root     string       `json:"root"`
	Files    []TempEntry  `json:"files"`
	Settings TempSettings `json:"settings"`
}

type TempPromoteRequest

type TempPromoteRequest struct {
	DestPath string `json:"dest_path"`
}

type TempReadBytesResponse added in v0.1.15

type TempReadBytesResponse struct {
	File          TempEntry `json:"file"`
	ContentBase64 string    `json:"content_base64"`
}

func NewTempReadBytesResponse added in v0.1.15

func NewTempReadBytesResponse(file TempEntry, content []byte) TempReadBytesResponse

func (TempReadBytesResponse) ContentBytes added in v0.1.15

func (r TempReadBytesResponse) ContentBytes() ([]byte, error)

type TempSettings

type TempSettings struct {
	AutoCleanup bool  `json:"auto_cleanup"`
	TTLSeconds  int64 `json:"ttl_seconds"`
	MaxBytes    int64 `json:"max_bytes"`
	TotalBytes  int64 `json:"total_bytes"`
	TotalFiles  int   `json:"total_files"`
}

type TempSettingsResponse

type TempSettingsResponse struct {
	Settings TempSettings `json:"settings"`
}

type TempSettingsUpdateRequest

type TempSettingsUpdateRequest struct {
	AutoCleanup *bool   `json:"auto_cleanup,omitempty"`
	TTLDays     int64   `json:"ttl_days"`
	MaxGB       float64 `json:"max_gb"`
}

Jump to

Keyboard shortcuts

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