(filePath: string)
| 21 | } |
| 22 | |
| 23 | export 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 | } |
no test coverage detected