(file: File)
| 1 | import axios from 'axios'; |
| 2 | |
| 3 | export const uploadFile = async (file: File) => { |
| 4 | try { |
| 5 | const formData = new FormData(); |
| 6 | formData.append('file', file); |
| 7 | const response = await axios.post('/api/upload', formData, { |
| 8 | headers: { 'Content-Type': 'multipart/form-data' }, |
| 9 | }); |
| 10 | return response.data; |
| 11 | } catch (error: any) { |
| 12 | throw error?.response?.data?.detail || 'File upload failed'; |
| 13 | } |
| 14 | }; |
| 15 | |
| 16 | export const fetchFiles = async () => { |
| 17 | try { |