Skip to main content

File Storage & Uploads

Multipart file upload handling for images, screenshots, and device assets.

Source: src/upload/

API Endpoints

MethodEndpointDescription
POST/uploadGeneral image upload
POST/upload/screenshotDevice screenshot upload
GET/upload/assetsList uploaded assets
GET/upload/assets/:idGet asset details
DELETE/upload/assets/:idDelete asset

Upload Validation

CheckRule
MIME typeimage/jpeg, image/png, image/webp, image/gif only
File sizeMax 10 MB
MultipartRequest must be multipart (req.isMultipart())
FilenameSanitized — random suffix via crypto.randomBytes(6), extension cleaned with regex

Storage

  • Directory: uploads/ (project root)
  • Screenshots: uploads/screenshots/
  • Directories auto-created on service init
  • Files served via static file serving or Cloudinary (production)

Screenshot Uploads

Device screenshots include:

  • deviceId — Required, validated against device ownership
  • userId — Attached manually (file uploads skip TenantInterceptor)
Security Note

File upload handlers bypass the standard TenantInterceptor. The userId must be manually attached in upload handlers to maintain tenant isolation.

Prisma Model

  • UploadAsset — Asset metadata (filename, path, size, device association)
  • ScreenshotsModule — Screenshot management layer
  • DevicesModule — Device ownership verification