Equipment Media

Back to docs

Equipment Media (Images & Short Videos)

This document explains how equipment media works, required env/migration steps, and upload limits.

Summary

  • New Prisma model LabEquipmentMedia stores uploaded images/videos for equipment.
  • Upload/delete flow:
    • Workspace UI uses server actions from src/actions/equipment.ts.
    • POST /api/equipment/{equipmentId}/media/upload remains available for multipart file uploads by lab editors.
    • GET /api/equipment/media/{mediaId} serves binary media. Private equipment media requires lab membership.
  • Upload limits (server-side):
    • Images: 5 MB
    • Videos: 20 MB

DB migration

After pulling these changes, run a Prisma migration locally and on your deployment:

npx prisma migrate dev --name add-equipment-media
# or for production workflows, generate SQL and apply via your deployment process
npx prisma migrate deploy

Environment & resource considerations

  • Current implementation stores media binaries in the database (Bytes). For small images and short videos this is acceptable, but for larger or many videos consider using S3 or another blob store and persist only URLs in the DB.
  • Keep an eye on DB size and backup strategies when allowing media uploads.

How to test locally

  1. Run database and apply migration (see above).
  2. Start dev server:
npm run dev
  1. As a lab editor/manager, open the lab workspace equipment page (/{labSlug}/app/equipment) and use the media section on each equipment card.
  2. Confirm media appears on the public equipment page (/{labSlug}/equipment).

Limits and validation

  • The server enforces MIME type checks (only image/* and video/*) and size limits above.
  • If needed, adjust MAX_IMAGE_BYTES and MAX_VIDEO_BYTES in both src/actions/equipment.ts and app/api/equipment/[equipmentId]/media/upload/route.ts.

Next improvements

  • Offload binary storage to S3 or similar and store references in DB.
  • Add image resizing/thumbnail generation on upload.
  • Add per-lab quota and moderation tools to prevent abuse.