feat: implement storage provider with local and S3 adapters

This commit is contained in:
2026-04-10 00:59:35 -03:00
parent fb8c07d32e
commit 98515550ca
8 changed files with 2260 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import {
LocalStorageAdapter,
S3StorageAdapter,
} from '@/lib/storage/storage.adapter';
import { StorageProvider } from '@/lib/storage/storage.interface';
/**
* Factory function to create the appropriate storage provider based on environment
*/
export function createStorageProvider(): StorageProvider {
const storageType = process.env.STORAGE_TYPE || 'local';
if (storageType === 's3') {
const bucketName = process.env.S3_BUCKET_NAME;
const region = process.env.S3_REGION || 'us-east-1';
if (!bucketName) {
throw new Error(
'S3_BUCKET_NAME environment variable is required when STORAGE_TYPE=s3'
);
}
return new S3StorageAdapter(bucketName, region);
}
// Default to local storage
return new LocalStorageAdapter();
}