MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / uploadDocument

Function uploadDocument

packages/baseai/src/deploy/index.ts:966–1000  ·  view source on GitHub ↗
(signedUrl: string, document: Blob)

Source from the content-addressed store, hash-verified

964}
965
966async function uploadDocument(signedUrl: string, document: Blob) {
967 let mimeType = document.type;
968
969 // Check if the MIME type is supported.
970 const isSupportedMimeType =
971 MEMORYSETS.ACCEPTED_MIME_TYPES.includes(mimeType);
972
973 // If not, default to text/plain.
974 if (!isSupportedMimeType) {
975 dlog(`Unsupported MIME type ${mimeType}. Defaulting to text/plain`);
976 mimeType = 'text/plain';
977 }
978
979 try {
980 const response = await fetch(signedUrl, {
981 method: 'PUT',
982 headers: {
983 'Content-Type': mimeType
984 },
985 body: document
986 });
987
988 if (!response.ok) {
989 const error = await response.text();
990 throw new Error(
991 `HTTP error! status: ${response.status}, message: ${error}`
992 );
993 }
994
995 return response;
996 } catch (error) {
997 dlog('Error in uploadDocument:', error);
998 throw error;
999 }
1000}
1001
1002export function getMemoryApiUrls({
1003 memoryName,

Callers 1

uploadDocumentsToMemoryFunction · 0.85

Calls 1

dlogFunction · 0.90

Tested by

no test coverage detected