filestore

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 15 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

Overview

Package filestore persists provider ownership for uploaded files.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("file mapping not found")

ErrNotFound indicates a requested file mapping was not found.

Functions

This section is empty.

Types

type ListFilter added in v0.1.87

type ListFilter struct {
	UserPath     string
	ProviderType string
	Purpose      string
}

ListFilter narrows a listing. Empty fields do not filter. UserPath keeps the mappings inside one subtree: the path itself and its descendants; root ("/") keeps every mapping that carries a path.

type MemoryStore

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

MemoryStore keeps file provider mappings in process memory.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates an empty in-memory file store.

func (*MemoryStore) Close

func (s *MemoryStore) Close() error

Close releases resources.

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(_ context.Context, id string) error

Delete removes one file mapping by id.

func (*MemoryStore) Get

func (s *MemoryStore) Get(_ context.Context, id string) (*StoredFile, error)

Get retrieves one file mapping by id.

func (*MemoryStore) List added in v0.1.87

func (s *MemoryStore) List(_ context.Context, filter ListFilter, limit int, after string) ([]*StoredFile, error)

List returns the mappings matching filter, newest first, after the cursor.

func (*MemoryStore) Upsert

func (s *MemoryStore) Upsert(_ context.Context, file *StoredFile) error

Upsert creates or replaces a file mapping.

type MongoDBStore

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

MongoDBStore stores file provider mappings in MongoDB.

func NewMongoDBStore

func NewMongoDBStore(database *mongo.Database) (*MongoDBStore, error)

NewMongoDBStore creates collection indexes if needed.

func (*MongoDBStore) Close

func (s *MongoDBStore) Close() error

Close is a no-op; Mongo client lifecycle is managed by storage layer.

func (*MongoDBStore) Delete

func (s *MongoDBStore) Delete(ctx context.Context, id string) error

Delete removes one file mapping by id.

func (*MongoDBStore) Get

func (s *MongoDBStore) Get(ctx context.Context, id string) (*StoredFile, error)

Get retrieves one file mapping by id.

func (*MongoDBStore) List added in v0.1.87

func (s *MongoDBStore) List(ctx context.Context, filter ListFilter, limit int, after string) ([]*StoredFile, error)

List returns the mappings matching filter, newest first, after the cursor.

func (*MongoDBStore) Upsert

func (s *MongoDBStore) Upsert(ctx context.Context, file *StoredFile) error

Upsert creates or replaces a file mapping.

type Result

type Result struct {
	Store Store
}

Result holds the initialized file store.

func New

func New(ctx context.Context, shared storage.Storage) (*Result, error)

New creates a file store on the shared storage connection.

func (*Result) Close

func (r *Result) Close() error

Close releases resources held by the file store.

type SQLStore added in v0.1.60

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

SQLStore stores file provider mappings in a SQL database.

func NewSQLStore added in v0.1.60

func NewSQLStore(ctx context.Context, db sqlx.DB) (*SQLStore, error)

NewSQLStore creates the file_mappings table and indexes if needed.

func (*SQLStore) Close added in v0.1.60

func (s *SQLStore) Close() error

Close is a no-op; connection lifecycle is managed by the storage layer.

func (*SQLStore) Delete added in v0.1.60

func (s *SQLStore) Delete(ctx context.Context, id string) error

Delete removes one file mapping by id.

func (*SQLStore) Get added in v0.1.60

func (s *SQLStore) Get(ctx context.Context, id string) (*StoredFile, error)

Get retrieves one file mapping by id.

func (*SQLStore) List added in v0.1.87

func (s *SQLStore) List(ctx context.Context, filter ListFilter, limit int, after string) ([]*StoredFile, error)

List returns the mappings matching filter, newest first, after the cursor.

func (*SQLStore) Upsert added in v0.1.60

func (s *SQLStore) Upsert(ctx context.Context, file *StoredFile) error

Upsert creates or replaces a file mapping.

type Store

type Store interface {
	Upsert(ctx context.Context, file *StoredFile) error
	Get(ctx context.Context, id string) (*StoredFile, error)
	// List returns mappings newest first, starting after the cursor id. The
	// cursor must exist and match the filter, else ErrNotFound.
	List(ctx context.Context, filter ListFilter, limit int, after string) ([]*StoredFile, error)
	Delete(ctx context.Context, id string) error
	Close() error
}

Store defines persistence operations for file provider mappings.

type StoredFile

type StoredFile struct {
	ID           string `json:"id" bson:"_id"`
	ProviderType string `json:"provider_type" bson:"provider_type"`
	Purpose      string `json:"purpose,omitempty" bson:"purpose,omitempty"`
	Filename     string `json:"filename,omitempty" bson:"filename,omitempty"`
	Bytes        int64  `json:"bytes,omitempty" bson:"bytes,omitempty"`
	CreatedAt    int64  `json:"created_at,omitempty" bson:"created_at,omitempty"`
	UserPath     string `json:"user_path,omitempty" bson:"user_path,omitempty"`
}

StoredFile maps an OpenAI-compatible file ID to the provider that owns it.

Jump to

Keyboard shortcuts

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