(filename)
| 186 | } |
| 187 | |
| 188 | export async function downloadDocument(filename) { |
| 189 | const res = await fetch(`${API_BASE}/documents/download/${encodeURIComponent(filename)}`, { |
| 190 | headers: getAuthHeaders(), |
| 191 | }); |
| 192 | if (!res.ok) throw new Error('Download failed'); |
| 193 | const blob = await res.blob(); |
| 194 | const url = window.URL.createObjectURL(blob); |
| 195 | const a = document.createElement('a'); |
| 196 | a.href = url; |
| 197 | a.download = filename; |
| 198 | document.body.appendChild(a); |
| 199 | a.click(); |
| 200 | a.remove(); |
| 201 | window.URL.revokeObjectURL(url); |
| 202 | } |
| 203 | |
| 204 | export async function deleteDocument(filename) { |
| 205 | const res = await fetch(`${API_BASE}/documents/delete`, { |
no test coverage detected