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

  1. Open Edit Panel – From Object Detail, user clicks Add / Replace Photo.
  2. Select File(s)<input type="file" multiple> accepts images only; previews shown.
  3. Supabase Upload – Client uploads each selected file directly to Supabase Storage using the JS SDK.
  4. Metadata Registration – After each upload the client calls POST /register-image/{object_id} with { public_url, storage_path } so the backend can insert the object_images row and update the main flag.
  5. 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.