Architecture
How the storage builder, manager, scopes, and adapters collaborate to deliver files.
Components
- Builder: Immutable chain that registers scopes, adapters, policies, hooks, logger, and telemetry. Produces a configured manager after merging environment input.
- Manager: High-level API (
upload,list,get,copy,move,stream,delete) that resolves paths, enforces policies, triggers hooks, and emits telemetry. - Adapter: Infrastructure-only implementation for S3, GCS, or custom backends. Receives normalized keys and content plus options (
contentType,cacheControl,public). - Scopes & Paths: Templates that turn identifiers into paths (
/users/[identifier]→/users/123). Combined with optionalbasePathto isolate environments.
Flow of an Upload
- Resolve: Manager strips
baseUrl(if a URL is passed), joinsbasePath, scope, and destination to form the key. - Infer: Determines filename, extension, and content type (or uses explicit override).
- Validate: Applies policies (size, MIME, extension). Throws
IGNITER_STORAGE_UPLOAD_POLICY_VIOLATIONon failure. - Hooks/Telemetry Start: Fires
onUploadStartedandigniter.storage.upload.startedwith attributes. - Replace (optional): Deletes matching files when
replaceis set; aborts on failure. - Adapter Write: Calls adapter
putwith cache control and public flag. - Build Response: Returns
IgniterStorageFilewith path, URL, name, extension, content type, and optional size. - Hooks/Telemetry End: Fires success or error hooks and telemetry with durations and codes.
Env Integration
IgniterStorageEnv reads IGNITER_STORAGE_URL, IGNITER_STORAGE_ADAPTER, IGNITER_STORAGE_BASE_PATH, provider creds, and policies. The builder merges env and explicit state, so code config always wins. This keeps environments consistent while letting tests override values locally.
Learn more in Adapters, enforce guardrails in Policies & Validation, and instrument behavior in Hooks & Telemetry.