From 5fddf4ff2b18d66ccb86bfc77a4105802c04fd25 Mon Sep 17 00:00:00 2001 From: gongzhiyong Date: Wed, 8 Apr 2026 18:32:13 +0800 Subject: [PATCH] fix: align uploadAttachment with backend API contract - Change FormData field name from "file" to "data" (backend expects "data") - Pass conversation_id as query parameter instead of form field - Add content_type and created_at to AttachmentData interface to match backend response shape Co-Authored-By: Claude Sonnet 4.6 (1M context) --- frontend/lib/api.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/lib/api.ts b/frontend/lib/api.ts index a70f8e8..f6addda 100644 --- a/frontend/lib/api.ts +++ b/frontend/lib/api.ts @@ -79,9 +79,11 @@ export async function fetchTicketSummary(): Promise { export interface AttachmentData { id: string; - blob_url: string; filename: string; + content_type: string; + blob_url: string; size_bytes: number; + created_at: string; } export async function uploadAttachment( @@ -89,12 +91,10 @@ export async function uploadAttachment( conversationId?: string, ): Promise { const form = new FormData(); - form.append("file", file); - if (conversationId) { - form.append("conversation_id", conversationId); - } + form.append("data", file); - const res = await fetch(`${API_URL}/api/attachments/upload`, { + const params = conversationId ? `?conversation_id=${conversationId}` : ""; + const res = await fetch(`${API_URL}/api/attachments/upload${params}`, { method: "POST", body: form, });