(files, dataset)
| 169 | } |
| 170 | |
| 171 | export async function uploadDocuments(files, dataset) { |
| 172 | const formData = new FormData(); |
| 173 | for (const file of files) { |
| 174 | formData.append('files', file); |
| 175 | } |
| 176 | formData.append('dataset', dataset); |
| 177 | |
| 178 | const res = await fetch(`${API_BASE}/documents/upload`, { |
| 179 | method: 'POST', |
| 180 | headers: getAuthHeaders(), |
| 181 | body: formData, |
| 182 | }); |
| 183 | const data = await res.json(); |
| 184 | if (!res.ok) throw new Error(data.error || 'Upload failed'); |
| 185 | return data; |
| 186 | } |
| 187 | |
| 188 | export async function downloadDocument(filename) { |
| 189 | const res = await fetch(`${API_BASE}/documents/download/${encodeURIComponent(filename)}`, { |
no test coverage detected