(
source: File[] | string,
_options?: ImportOptions,
onProgress?: (p: ImportProgress) => void
)
| 241 | } |
| 242 | |
| 243 | async importDirectory( |
| 244 | source: File[] | string, |
| 245 | _options?: ImportOptions, |
| 246 | onProgress?: (p: ImportProgress) => void |
| 247 | ): Promise<ImportResult> { |
| 248 | if (typeof source === 'string') { |
| 249 | return { success: false, error: 'Directory path import is not supported in Web mode' } |
| 250 | } |
| 251 | |
| 252 | if (source.length === 0) { |
| 253 | return { success: false, error: 'No files in directory' } |
| 254 | } |
| 255 | |
| 256 | const form = new FormData() |
| 257 | for (const file of source) { |
| 258 | form.append('files', file) |
| 259 | form.append('relativePaths', file.webkitRelativePath || file.name) |
| 260 | } |
| 261 | |
| 262 | const res = await fetchWithAuth(`${getBaseUrl()}/import-directory`, { method: 'POST', body: form }) |
| 263 | |
| 264 | if (!res.ok) { |
| 265 | const text = await res.text() |
| 266 | return { success: false, error: `HTTP ${res.status}: ${text}` } |
| 267 | } |
| 268 | |
| 269 | return consumeSseStream<ImportResult>(res, { success: false, error: 'Unknown error' }, onProgress) |
| 270 | } |
| 271 | } |
nothing calls this directly
no test coverage detected