MCPcopy
hub / github.com/simstudioai/sim / parseDataURI

Function parseDataURI

apps/sim/lib/knowledge/documents/document-processor.ts:823–839  ·  view source on GitHub ↗
(fileUrl: string, filename: string, mimeType: string)

Source from the content-addressed store, hash-verified

821}
822
823async function parseDataURI(fileUrl: string, filename: string, mimeType: string): Promise<string> {
824 const [header, base64Data] = fileUrl.split(',')
825 if (!base64Data) {
826 throw new Error('Invalid data URI format')
827 }
828
829 if (mimeType === 'text/plain') {
830 return header.includes('base64')
831 ? Buffer.from(base64Data, 'base64').toString('utf8')
832 : decodeURIComponent(base64Data)
833 }
834
835 const extension = resolveParserExtension(filename, mimeType, 'txt')
836 const buffer = Buffer.from(base64Data, 'base64')
837 const result = await parseBuffer(buffer, extension)
838 return result.content
839}
840
841async function parseHttpFile(
842 fileUrl: string,

Callers 1

parseWithFileParserFunction · 0.85

Calls 3

resolveParserExtensionFunction · 0.90
parseBufferFunction · 0.90
toStringMethod · 0.45

Tested by

no test coverage detected