From the first day of development, the SSA Health Platform treats file storage as an external dependency — not a built-in capability. By routing all file operations through aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/LMendoza70/SSA/llms.txt
Use this file to discover all available pages before exploring further.
StorageProvider interface, the platform eliminates vendor lock-in at the infrastructure level: a developer running the system locally uses the filesystem; a production deployment in AWS uses S3; a future migration to Azure changes a single environment variable, not a single line of business logic. The Multimedia Module, CMS, and any other module that handles files are completely unaware of where or how files are physically stored. This separation is enforced as an architectural constraint, not merely a convention.
StorageProvider Interface
All file operations in the platform go through theStorageProvider interface. No service, controller, or domain class is permitted to access the filesystem, an AWS SDK, or any cloud storage client directly. The interface is injected via NestJS dependency injection, making providers interchangeable and individually testable.
The
upload method returns the canonical storage path for the file. That path is stored in the database and later passed to getUrl() to generate the public URL. This two-step design ensures URLs can be regenerated (e.g., after migrating providers) without touching the stored path.Available Providers
The platform ships with four concrete implementations ofStorageProvider. The active provider is selected at startup based on the STORAGE_DRIVER environment variable.
| Provider | Use Case | Config Key |
|---|---|---|
LocalStorageProvider | Development, on-premise deployments | STORAGE_DRIVER=local |
S3StorageProvider | AWS production environments | STORAGE_DRIVER=s3 |
AzureBlobStorageProvider | Azure production environments | STORAGE_DRIVER=azure |
GCSStorageProvider | Google Cloud production environments | STORAGE_DRIVER=gcs |
LocalStorageProvider
Writes files to the local filesystem under the configured path. Suitable for local development and on-premise servers where cloud storage is not available. Files are served as static assets by NestJS.
S3StorageProvider
Uploads files to an Amazon S3 bucket using the AWS SDK. The recommended provider for AWS-hosted production deployments.
AzureBlobStorageProvider
Stores files in an Azure Blob Storage container using the Azure SDK. Use for deployments in the Azure ecosystem.
GCSStorageProvider
Uploads files to a Google Cloud Storage bucket using a service account key file. Use for deployments on Google Cloud Platform.
Configuration
Each provider is configured exclusively through environment variables. Only the variables for the activeSTORAGE_DRIVER need to be present.
File Deduplication
The Multimedia Module ensures that the same file is never stored twice, regardless of how many times it is uploaded. Before persisting any incoming file, the system computes a content hash (SHA-256) of the file’s binary data and checks theMediaAsset table for an existing record with that hash.
File arrives
A multipart upload request reaches the Multimedia Module endpoint. The file is held in memory by Multer — it has not been written to storage yet.
Hash computed
The service computes a SHA-256 hash of the file buffer. This hash uniquely identifies the file’s content, independent of its filename or upload metadata.
Duplicate check
The repository queries
MediaAsset for a record where hash = computedHash AND deletedAt IS NULL. If a match is found, the existing MediaAsset ID is returned immediately.Supported File Types
The platform accepts the following file types through the Multimedia Module. Uploads outside this list are rejected with a422 Unprocessable Entity response before reaching the storage layer.
| Category | Formats |
|---|---|
| Images | JPEG, PNG, WebP, SVG |
| Videos | MP4, WebM |
| Documents | |
| Audio | MP3, OGG |
MIME type validation is performed server-side on the binary content of the file, not on the filename extension. Renaming a
.exe to .jpg will not bypass validation.Usage in Modules
Modules that need to handle files declare a dependency onStorageProvider in their NestJS module definition and inject it into the relevant service:
Multimedia Module
How
MediaAsset records are managed, deduplicated, and reused across content.Architecture Overview
Where the storage abstraction fits within the Clean Architecture layers.
Deployment
Configuring storage provider environment variables in production environments.