Service Layer medium complexity mobile
0
Dependencies
0
Dependents
0
Entities
0
Integrations

Description

Orchestrates the full attachment lifecycle from file selection through compression, upload, and metadata persistence. It compresses images before upload to reduce storage costs and coordinates with FileStorageClient for remote storage and AttachmentRepository for local metadata. The service handles offline queuing so attachments are synchronized when the device comes online.

Feature: Document Attachments

attachment-service

Sources & reasoning

Lines 107-108 give the exact use-case (invitations, screenshots for Bufdir auditing). Line 348 places it in Fase 2 (v1.0). The needs matrix marks it NICE TO HAVE / Fase 2, consistent with should_have at v1.0.

Responsibilities

  • Compress image files to a target size threshold before upload
  • Coordinate with FileStorageClient to upload files to remote storage
  • Persist attachment metadata to AttachmentRepository after successful upload
  • Queue pending uploads when offline and flush the queue on connectivity restore
  • Propagate upload progress events back to the UI layer

Interfaces

attachFile(activityId: string, file: FileHandle): Promise<Attachment>
deleteAttachment(attachmentId: string): Promise<void>
getAttachments(activityId: string): Promise<Attachment[]>
compressImage(file: FileHandle, targetKB: number): Promise<FileHandle>
flushPendingUploads(): Promise<UploadResult[]>