Use Case: Upload an Image for an Object
Use Case: Upload an Image for an Object
Overview
Users can add or update images for an existing ObjectInstance. Images are stored in Supabase Storage and associated rows are written to object_images.
Workflow Steps
- Open Edit Panel – From Object Detail, user clicks Add / Replace Photo.
- Select File(s) –
<input type="file" multiple>accepts images only; previews shown. - Supabase Upload – Client uploads each selected file directly to Supabase Storage using the JS SDK.
- Metadata Registration – After each upload the client calls
POST /register-image/{object_id}with{ public_url, storage_path }so the backend can insert theobject_imagesrow and update themainflag. - Optimistic UI – Show placeholder thumbnail while upload completes; on success update image URL in state.
Storage Rules
- Bucket:
object-images - Path:
objects/ObjectInstance/{object_id}/{filename}
Reactivity Requirements
Follow guidelines in image-management.md – reset _imageError flag, update lastUpdate store key to trigger re-render.
Error Handling
Display toast on failed upload; allow retry.