local

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package local provides local filesystem-based storage implementation.

Index

Constants

View Source
const (

	// DefaultMaxFileSize is the default maximum file size (50 MB).
	DefaultMaxFileSize = 50 * 1024 * 1024
)

Variables

View Source
var ErrFileTooLarge = fmt.Errorf("file size exceeds maximum allowed size")

ErrFileTooLarge is returned when data exceeds the configured MaxFileSize.

Functions

This section is empty.

Types

type FileStore

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

FileStore implements MediaStorageService using local filesystem storage.

func NewFileStore

func NewFileStore(config FileStoreConfig, opts ...FileStoreOption) (*FileStore, error)

NewFileStore creates a new local filesystem storage backend. Optional FileStoreOption values can be passed to override config fields.

func (*FileStore) DeleteMedia

func (fs *FileStore) DeleteMedia(ctx context.Context, reference storage.Reference) error

DeleteMedia implements MediaStorageService.DeleteMedia

func (*FileStore) Flush added in v1.3.10

func (fs *FileStore) Flush() error

Flush persists any pending dedup index changes to disk. Call this periodically or before shutting down to ensure the index is saved.

func (*FileStore) GetURL

func (fs *FileStore) GetURL(ctx context.Context, reference storage.Reference, expiry time.Duration) (string, error)

GetURL implements MediaStorageService.GetURL

func (*FileStore) RetrieveMedia

func (fs *FileStore) RetrieveMedia(ctx context.Context, reference storage.Reference) (*types.MediaContent, error)

RetrieveMedia implements MediaStorageService.RetrieveMedia

func (*FileStore) StoreMedia

func (fs *FileStore) StoreMedia(ctx context.Context, content *types.MediaContent, metadata *storage.MediaMetadata) (storage.Reference, error)

StoreMedia implements MediaStorageService.StoreMedia

type FileStoreConfig

type FileStoreConfig struct {
	// BaseDir is the root directory for media storage
	BaseDir string

	// Organization determines how files are organized in directories
	Organization storage.OrganizationMode

	// EnableDeduplication enables content-based deduplication using SHA-256 hashing
	EnableDeduplication bool

	// DefaultPolicy is the default retention policy to apply to new media
	DefaultPolicy string

	// MaxFileSize is the maximum allowed file size in bytes.
	// If zero, DefaultMaxFileSize (50 MB) is used.
	// Set to a negative value to disable the size limit.
	MaxFileSize int64
}

FileStoreConfig configures the local filesystem storage backend.

type FileStoreOption added in v1.3.10

type FileStoreOption func(*FileStoreConfig)

FileStoreOption is a functional option for configuring a FileStore.

func WithMaxFileSize added in v1.3.10

func WithMaxFileSize(size int64) FileStoreOption

WithMaxFileSize returns an option that sets the maximum file size in bytes. Set to a negative value to disable the size limit.

Jump to

Keyboard shortcuts

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