Equipment Media
Back to docsEquipment Media (Images & Short Videos)
This document explains how equipment media works, required env/migration steps, and upload limits.
Summary
- New Prisma model
LabEquipmentMediastores uploaded images/videos for equipment. - Upload/delete flow:
- Workspace UI uses server actions from
src/actions/equipment.ts. POST /api/equipment/{equipmentId}/media/uploadremains available for multipartfileuploads by lab editors.GET /api/equipment/media/{mediaId}serves binary media. Private equipment media requires lab membership.
- Workspace UI uses server actions from
- 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
- Run database and apply migration (see above).
- Start dev server:
npm run dev
- As a lab editor/manager, open the lab workspace equipment page (
/{labSlug}/app/equipment) and use the media section on each equipment card. - Confirm media appears on the public equipment page (
/{labSlug}/equipment).
Limits and validation
- The server enforces MIME type checks (only
image/*andvideo/*) and size limits above. - If needed, adjust
MAX_IMAGE_BYTESandMAX_VIDEO_BYTESin bothsrc/actions/equipment.tsandapp/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.
