Documentation
¶
Overview ¶
Package filestore persists provider ownership for uploaded files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("file mapping not found")
ErrNotFound indicates a requested file mapping was not found.
Functions ¶
This section is empty.
Types ¶
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) 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) 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) Upsert ¶
func (s *MongoDBStore) Upsert(ctx context.Context, file *StoredFile) error
Upsert creates or replaces a file mapping.
type PostgreSQLStore ¶
type PostgreSQLStore struct {
// contains filtered or unexported fields
}
PostgreSQLStore stores file provider mappings in PostgreSQL.
func NewPostgreSQLStore ¶
NewPostgreSQLStore creates the file_mappings table and indexes if needed.
func (*PostgreSQLStore) Close ¶
func (s *PostgreSQLStore) Close() error
Close is a no-op; pool lifecycle is managed by storage layer.
func (*PostgreSQLStore) Delete ¶
func (s *PostgreSQLStore) Delete(ctx context.Context, id string) error
Delete removes one file mapping by id.
func (*PostgreSQLStore) Get ¶
func (s *PostgreSQLStore) Get(ctx context.Context, id string) (*StoredFile, error)
Get retrieves one file mapping by id.
func (*PostgreSQLStore) Upsert ¶
func (s *PostgreSQLStore) Upsert(ctx context.Context, file *StoredFile) error
Upsert creates or replaces a file mapping.
type Result ¶
Result holds the initialized file store and optional owned storage.
func NewWithSharedStorage ¶
NewWithSharedStorage creates a file store using a shared storage connection.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore stores file provider mappings in SQLite.
func NewSQLiteStore ¶
func NewSQLiteStore(db *sql.DB) (*SQLiteStore, error)
NewSQLiteStore creates the file_mappings table and indexes if needed.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
Close is a no-op; DB lifecycle is managed by storage layer.
func (*SQLiteStore) Delete ¶
func (s *SQLiteStore) Delete(ctx context.Context, id string) error
Delete removes one file mapping by id.
func (*SQLiteStore) Get ¶
func (s *SQLiteStore) Get(ctx context.Context, id string) (*StoredFile, error)
Get retrieves one file mapping by id.
func (*SQLiteStore) Upsert ¶
func (s *SQLiteStore) 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)
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.