workspace-v1/projects/erp-construccion/docs/02-definicion-modulos/MAE-016-gestion-documental/especificaciones/ET-DOC-002-servicio de almacenamiento s3.md
rckrdmrd 66161b1566 feat: Workspace-v1 complete migration with NEXUS v3.4
Sistema NEXUS v3.4 migrado con:

Estructura principal:
- core/orchestration: Sistema SIMCO + CAPVED (27 directivas, 28 perfiles)
- core/catalog: Catalogo de funcionalidades reutilizables
- shared/knowledge-base: Base de conocimiento compartida
- devtools/scripts: Herramientas de desarrollo
- control-plane/registries: Control de servicios y CI/CD
- orchestration/: Configuracion de orquestacion de agentes

Proyectos incluidos (11):
- gamilit (submodule -> GitHub)
- trading-platform (OrbiquanTIA)
- erp-suite con 5 verticales:
  - erp-core, construccion, vidrio-templado
  - mecanicas-diesel, retail, clinicas
- betting-analytics
- inmobiliaria-analytics
- platform_marketing_content
- pos-micro, erp-basico

Configuracion:
- .gitignore completo para Node.js/Python/Docker
- gamilit como submodule (git@github.com:rckrdmrd/gamilit-workspace.git)
- Sistema de puertos estandarizado (3005-3199)

Generated with NEXUS v3.4 Migration System
EPIC-010: Configuracion Git y Repositorios
2026-01-04 03:37:42 -06:00

1.2 KiB

ET-DOC-002: Servicio de Almacenamiento S3

ID: ET-DOC-002 | Módulo: MAE-016

Storage Service

@Injectable()
export class StorageService {
  private s3: S3;

  async upload(file: Express.Multer.File, metadata: FileMetadata): Promise<string> {
    const key = this.generateKey(metadata);
    
    await this.s3.upload({
      Bucket: process.env.S3_BUCKET,
      Key: key,
      Body: file.buffer,
      ContentType: file.mimetype,
      ServerSideEncryption: 'AES256',
      Metadata: {
        projectId: metadata.projectId,
        uploadedBy: metadata.uploadedBy,
        type: metadata.type
      }
    }).promise();
    
    return key;
  }

  async download(key: string): Promise<Buffer> {
    const result = await this.s3.getObject({
      Bucket: process.env.S3_BUCKET,
      Key: key
    }).promise();
    
    return result.Body as Buffer;
  }

  private generateKey(metadata: FileMetadata): string {
    const { constructoraId, projectId, type } = metadata;
    const date = new Date();
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    return `${constructoraId}/${projectId}/${type}/${year}/${month}/${uuidv4()}`;
  }
}

Generado: 2025-11-21