MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / importFile

Method importFile

src/services/import/fetch.ts:58–80  ·  view source on GitHub ↗
(
    file: File | string,
    options?: ImportOptions,
    onProgress?: (p: ImportProgress) => void
  )

Source from the content-addressed store, hash-verified

56
57export class FetchImportAdapter implements ImportAdapter {
58 async importFile(
59 file: File | string,
60 options?: ImportOptions,
61 onProgress?: (p: ImportProgress) => void
62 ): Promise<ImportResult> {
63 if (typeof file === 'string') {
64 return { success: false, error: 'File path import is not supported in Web mode' }
65 }
66
67 const form = new FormData()
68 form.append('file', file)
69 if (options?.formatId) form.append('formatId', options.formatId)
70 if (options?.chatIndex !== undefined) form.append('chatIndex', String(options.chatIndex))
71
72 const res = await fetchWithAuth(`${getBaseUrl()}/import`, { method: 'POST', body: form })
73
74 if (!res.ok) {
75 const text = await res.text()
76 return { success: false, error: `HTTP ${res.status}: ${text}` }
77 }
78
79 return consumeSseStream<ImportResult>(res, { success: false, error: 'Unknown error' }, onProgress)
80 }
81
82 async detectFormat(file: File | string): Promise<FormatInfo | null> {
83 if (typeof file === 'string') return null

Callers

nothing calls this directly

Calls 4

fetchWithAuthFunction · 0.90
getBaseUrlFunction · 0.90
consumeSseStreamFunction · 0.85
textMethod · 0.80

Tested by

no test coverage detected