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) <noreply@anthropic.com>
This commit is contained in:
gongzhiyong
2026-04-08 18:32:13 +08:00
co-authored by Claude Sonnet 4.6
parent 915aaef30b
commit 5fddf4ff2b
+6 -6
View File
@@ -79,9 +79,11 @@ export async function fetchTicketSummary(): Promise<TicketSummaryData> {
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<AttachmentData> {
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,
});