MCPcopy Create free account
hub / github.com/CommandCodeAI/BaseAI / getSignedUploadUrl

Function getSignedUploadUrl

packages/baseai/src/deploy/index.ts:881–927  ·  view source on GitHub ↗
({
	documentName,
	memoryName,
	account,
	meta
}: {
	documentName: string;
	memoryName: string;
	account: Account;
	meta: Record<string, string>;
})

Source from the content-addressed store, hash-verified

879}
880
881async function getSignedUploadUrl({
882 documentName,
883 memoryName,
884 account,
885 meta
886}: {
887 documentName: string;
888 memoryName: string;
889 account: Account;
890 meta: Record<string, string>;
891}): Promise<string> {
892 const { uploadDocument } = getMemoryApiUrls({
893 memoryName
894 });
895
896 try {
897 const response = await fetch(uploadDocument, {
898 method: 'POST',
899 headers: {
900 'Content-Type': 'application/json',
901 Authorization: `Bearer ${account.apiKey}`
902 },
903 body: JSON.stringify({
904 meta,
905 memoryName,
906 fileName: documentName
907 })
908 });
909
910 if (!response.ok) {
911 const errorData = (await response.json()) as ErrorResponse;
912 throw new Error(
913 `HTTP error! status: ${response.status}, message: ${errorData.error?.message}`
914 );
915 }
916 const { signedUrl } = (await response.json()) as { signedUrl: string };
917
918 if (!signedUrl) {
919 throw new Error('Invalid signedUrl received from API');
920 }
921
922 return signedUrl;
923 } catch (error) {
924 dlog('Error in getSignedUploadUrl:', error);
925 throw error;
926 }
927}
928
929async function deleteDocument({
930 documentName,

Callers 1

uploadDocumentsToMemoryFunction · 0.85

Calls 2

dlogFunction · 0.90
getMemoryApiUrlsFunction · 0.85

Tested by

no test coverage detected