MCPcopy Create free account
hub / github.com/PromtEngineer/localGPT / uploadFiles

Method uploadFiles

src/lib/api.ts:296–320  ·  view source on GitHub ↗
(sessionId: string, files: File[])

Source from the content-addressed store, hash-verified

294 }
295
296 async uploadFiles(sessionId: string, files: File[]): Promise<{
297 message: string;
298 uploaded_files: {filename: string, stored_path: string}[];
299 }> {
300 try {
301 const formData = new FormData();
302 files.forEach((file) => {
303 formData.append('files', file, file.name);
304 });
305
306 const response = await fetch(`${API_BASE_URL}/sessions/${sessionId}/upload`, {
307 method: 'POST',
308 body: formData,
309 });
310
311 if (!response.ok) {
312 const errorData = await response.json().catch(() => ({ error: 'Upload failed' }));
313 throw new Error(`Upload error: ${errorData.error || response.statusText}`);
314 }
315 return await response.json();
316 } catch (error) {
317 console.error('File upload failed:', error);
318 throw error;
319 }
320 }
321
322 async indexDocuments(sessionId: string): Promise<{ message: string }> {
323 try {

Callers 1

sendMessageFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected