Files
resolutionflow/frontend/src/api/uploads.ts
chihlasm f87f3d47de feat(evidence): add upload types and API client for frontend
- FileUploadResponse and PendingUpload types in types/upload.ts
- uploadsApi with upload(), getUrl(), list(), remove() methods
- Exported from types/index.ts and api/index.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 03:22:57 +00:00

33 lines
1014 B
TypeScript

import apiClient from './client'
import type { FileUploadResponse } from '@/types/upload'
export const uploadsApi = {
async upload(file: File, sessionId?: string): Promise<FileUploadResponse> {
const formData = new FormData()
formData.append('file', file)
if (sessionId) formData.append('session_id', sessionId)
const response = await apiClient.post<FileUploadResponse>('/uploads', formData, {
headers: { 'Content-Type': 'multipart/form-data' },
})
return response.data
},
async getUrl(id: string): Promise<string> {
const response = await apiClient.get<{ url: string }>(`/uploads/${id}/url`)
return response.data.url
},
async list(sessionId: string): Promise<FileUploadResponse[]> {
const response = await apiClient.get<FileUploadResponse[]>('/uploads', {
params: { session_id: sessionId },
})
return response.data
},
async remove(id: string): Promise<void> {
await apiClient.delete(`/uploads/${id}`)
},
}
export default uploadsApi