MCPcopy Create free account
hub / github.com/SecureAI-Tools/SecureAI-Tools / uploadDocument

Function uploadDocument

apps/web/lib/fe/document-utils.ts:64–90  ·  view source on GitHub ↗
(
  documentCollectionId: Id<DocumentCollectionCreateRequest>,
  file: File,
  indexingMode: IndexingMode,
)

Source from the content-addressed store, hash-verified

62}
63
64const uploadDocument = async (
65 documentCollectionId: Id<DocumentCollectionCreateRequest>,
66 file: File,
67 indexingMode: IndexingMode,
68): Promise<DocumentResponse> => {
69 const formData = new FormData();
70 formData.append("file", file);
71 formData.append("indexingMode", indexingMode);
72
73 const res = await fetch(
74 uploadDocumentApiPath(documentCollectionId),
75 {
76 method: "POST",
77 body: formData,
78 },
79 );
80
81 if (!res.ok) {
82 throw new FetchError(
83 "An error occurred while fetching the data.",
84 res.status,
85 await res.json(),
86 );
87 }
88
89 return await res.json();
90};

Callers 1

createDocumentFunction · 0.85

Calls 1

uploadDocumentApiPathFunction · 0.90

Tested by

no test coverage detected