feat(storage): phase 5 — replace Supabase storage with local filesystem + HMAC evidence serving

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-23 22:14:54 +08:00
co-authored by Claude Sonnet 4.6
parent dacc1a5265
commit e5f74c367d
4 changed files with 169 additions and 17 deletions
+3 -5
View File
@@ -1,8 +1,7 @@
import { NextResponse } from 'next/server'
import { createClient } from '@/lib/supabase/server'
import { getSession } from '@/lib/auth/get-session'
import { validateIncidentInput, validateTypeDetails, type IncidentType, type MedicalStatus } from '@/lib/incidents/validate'
import { uploadEvidenceFile } from '@/lib/supabase/storage'
import { uploadEvidenceFile } from '@/lib/storage/evidence'
import { sendNewIncidentEmail } from '@/lib/notifications/email'
import { sendWhatsAppMessage } from '@/lib/notifications/whatsapp'
import { createInAppNotifications } from '@/lib/notifications/in-app'
@@ -148,12 +147,11 @@ async function handlePost(request: Request) {
})
})
// Evidence upload — storage still uses supabase (Phase 5 replaces this)
const supabase = await createClient()
// Evidence upload — local filesystem storage with HMAC-signed URLs
const evidenceInserts: Array<typeof evidenceFiles.$inferInsert> = []
for (const file of files) {
try {
const { publicUrl, hash } = await uploadEvidenceFile(supabase, file, incidentId, 'report', session.sub)
const { publicUrl, hash } = await uploadEvidenceFile(file, incidentId, 'report', session.sub)
evidenceInserts.push({
incidentId,
stage: 'report',