Skip to content

feat: add signed photo uploads and a per-space quota - #13

Merged
Filionus merged 4 commits into
mainfrom
feat/b1-b3-signed-photos
Nov 28, 2026
Merged

Filionus merged 4 commits into
mainfrom
feat/b1-b3-signed-photos

Conversation

@ChargingCrystal

@ChargingCrystal ChargingCrystal commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

B1 and B3 / F3

Adds migration 005_signed_gallery.sql for confirmed photo metadata and a 50 MiB per-space quota. Photo bytes go directly from the browser to private Supabase Storage.

Quota accounting now counts a 5 MiB hold only while the reservation is open, unexpired, and unconfirmed. Confirmation closes the reservation and the stored object counts by size. Deleting that object frees its quota immediately. An expired hold gives way to any stored object left behind. The app keeps the existing signing window and transfer grace period.

Frontend impact

  1. Send POST /api/photos/upload-url with {"mime":"image/png","size":5242880}. The response includes uploadId, path, signedUrl, and token.
  2. Upload the file directly to the private gallery bucket with uploadToSignedUrl(path, token, file).
  3. Send POST /api/photos/confirm with {"uploadId":"<uuid>"} to register the photo. Confirmation remains safe to retry.

The old binary POST returns 405. GET /api/photos lists confirmed metadata and five-minute signed URLs. Deleting a missing or foreign photo returns 404 not_found. Issuing a new 5 MiB hold that would exceed the quota returns 409 quota_exceeded. The three frontend translations are on main via #12.

Verification

  • Rebased on aef3871. Verified all unrelated README API rows and all pre-existing isolation tests survived. The README has 20 API rows.
  • Test-only commit 9ddf947 reproduced three quota failures. Five PGlite cases cover 12 sequential small uploads, exact stored-byte accounting, immediate release after deletion, expiry and abandoned files, and the full-space limit.
  • npm test passed with 515 tests. npm run build passed.

Review note

Quota checks run when issuing a new reservation. Closing an app reservation does not revoke an already-issued Supabase upload token, so a signed upload can still succeed against its deleted path until the token expires. The accounting includes such stored bytes on subsequent checks. Live Storage replay was not tested here. Supabase signed-upload handler

@ChargingCrystal
ChargingCrystal force-pushed the feat/b1-b3-signed-photos branch from 555a31a to d9dfe65 Compare November 28, 2026 14:01
@ChargingCrystal
ChargingCrystal marked this pull request as ready for review November 28, 2026 14:03
@Filionus
Filionus merged commit a6b4eb2 into main Nov 28, 2026
1 check passed
@Filionus
Filionus deleted the feat/b1-b3-signed-photos branch November 28, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants