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>
This commit is contained in:
@@ -29,3 +29,4 @@ export { flowProposalsApi } from './flowProposals'
|
||||
export { flowpilotAnalyticsApi } from './flowpilotAnalytics'
|
||||
export { notificationsApi } from './notifications'
|
||||
export { publicTemplatesApi } from './publicTemplates'
|
||||
export { uploadsApi, default as uploadsApiDefault } from './uploads'
|
||||
|
||||
32
frontend/src/api/uploads.ts
Normal file
32
frontend/src/api/uploads.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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
|
||||
Reference in New Issue
Block a user