MCPcopy Index your code
hub / github.com/vercel/hyper / getBase64FileData

Function getBase64FileData

lib/utils/file.ts:23–36  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

21}
22
23export function getBase64FileData(filePath: string): Promise<string | null> {
24 return new Promise((resolve): void => {
25 return fs.readFile(filePath, (err, data) => {
26 if (err) {
27 // Gracefully fail with a warning
28 console.warn('There was an error reading the file at the local location:', err);
29 return resolve(null);
30 }
31
32 const base64Data = Buffer.from(data).toString('base64');
33 return resolve(base64Data);
34 });
35 });
36}

Callers 1

fetchFileDataFunction · 0.90

Calls 3

resolveFunction · 0.85
warnMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected