Skip to content

[BE-06] Set up AWS S3 file upload service with Multer for asset documents and images #879

Description

@yusuftomilola

Overview

Asset documents (invoices, warranties, manuals) and images need to be stored in cloud object storage. @aws-sdk/client-s3 and multer are installed but no upload service exists. This is a dependency for asset document management (BE-25) and user avatar uploads (BE-16).

Context

  • package.json has @aws-sdk/client-s3@3.975.0 and multer@2.0.2
  • backend/.env.example does not yet have S3 env vars — they need to be added
  • Uploaded files must be stored under unique UUID-based keys, never original filenames (prevents path traversal)
  • Files must not be publicly accessible by default — use pre-signed URLs for retrieval

Acceptance Criteria

  • Add AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_S3_BUCKET to backend/.env.example
  • Create src/file/file.service.ts with upload(file: Express.Multer.File, folder: string): Promise<string> returning the S3 object key
  • Create file.service.ts method getPresignedUrl(key: string, expiresInSeconds: number): Promise<string>
  • Create file.service.ts method delete(key: string): Promise<void>
  • Create a reusable Multer config that whitelists MIME types: image/jpeg, image/png, image/webp, application/pdf and enforces a 10MB max file size
  • Register FileModule in AppModule and export FileService for use by other modules

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions