Skip to content

BACKEND: Create File Upload and Management Service #413

@yusuftomilola

Description

@yusuftomilola

Description:
Build a comprehensive file upload service supporting profile pictures, documents, receipts, and biometric images with AWS S3/CloudFlare R2 storage, image optimization, and CDN integration.

Acceptance Criteria:

  • POST /api/files/upload endpoint - Upload single file
  • POST /api/files/upload-multiple endpoint - Upload multiple files
  • GET /api/files/:id endpoint - Get file metadata
  • GET /api/files/:id/download endpoint - Download file
  • DELETE /api/files/:id endpoint - Delete file
  • Support file types: images (JPEG, PNG, WebP), PDFs, documents (DOC, DOCX)
  • File size limits: Images (5MB), Documents (10MB), PDFs (20MB)
  • Image optimization (compression, resizing, format conversion)
  • Generate thumbnails for images (3 sizes: small, medium, large)
  • Virus scanning with ClamAV
  • Store files in AWS S3 or CloudFlare R2
  • Generate signed URLs for private files (1-hour expiry)
  • CDN integration for public files
  • Track file metadata (size, mime type, uploader, upload date)
  • Automatic cleanup of orphaned files (30 days)
  • Rate limiting (20 uploads per hour per user)

Technical Requirements:

  • Use @nestjs/platform-express with Multer
  • Use @aws-sdk/client-s3 for S3 operations
  • Use sharp for image processing
  • Use file-type for MIME type detection
  • Use clamscan for virus scanning
  • Implement streaming for large files
  • Create custom validators for file types and sizes

Files to Create:

backend/src/
├── files/
│   ├── files.module.ts
│   ├── files.controller.ts
│   ├── files.service.ts
│   ├── storage/
│   │   ├── storage.interface.ts
│   │   ├── s3-storage.service.ts
│   │   └── local-storage.service.ts (for development)
│   ├── processors/
│   │   ├── image-processor.service.ts
│   │   └── virus-scanner.service.ts
│   ├── validators/
│   │   ├── file-type.validator.ts
│   │   └── file-size.validator.ts
│   ├── dto/
│   │   ├── upload-file.dto.ts
│   │   └── file-filter.dto.ts
│   ├── entities/
│   │   └── file.entity.ts
│   └── decorators/
│       └── file-upload.decorator.ts
└── config/
    └── storage.config.ts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions