Skip to main content

Storage Module

src/app/core/storage/

Servicio singleton para subir, descargar y eliminar archivos en S3 / MinIO.

Configuración

Usa las variables de entorno del grupo storage:

STORAGE_ENDPOINT → URL de MinIO o S3
STORAGE_ACCESS_KEY
STORAGE_SECRET_KEY
STORAGE_BUCKET
STORAGE_REGION

La conectividad se verifica en el arranque desde src/bootstrap/check-storage.ts.

StorageService — métodos principales

MétodoDescripción
upload(file, key)Sube un archivo al bucket, retorna la URL pública
download(key)Descarga un archivo por su key
delete(key)Elimina un archivo del bucket

Integración

StorageModule exporta StorageService y se importa globalmente. El módulo file lo consume para persistir los metadatos en MongoDB tras la subida.

// En FileService
const url = await this.storageService.upload(file.buffer, filename);
await this.fileRepository.create({ url, filename, mimetype, size, ... });