( downloaded: any, )
| 627 | |
| 628 | const normalizeDownloadedMedia = async ( |
| 629 | downloaded: any, |
| 630 | ): Promise<Buffer | null> => { |
| 631 | if (!downloaded) return null; |
| 632 | if (Buffer.isBuffer(downloaded)) return downloaded; |
| 633 | if (typeof downloaded === "string" && downloaded.length > 0) { |
| 634 | try { |
| 635 | const stat = await fs.promises.stat(downloaded); |
| 636 | if (!stat.isFile()) return null; |
| 637 | return await fs.promises.readFile(downloaded); |
| 638 | } catch { |
| 639 | return null; |
| 640 | } |
| 641 | } |
| 642 | return null; |
| 643 | }; |
| 644 | |
| 645 | const getImageExtensionForMime = (mimeType: string): string => { |
| 646 | if (mimeType === "image/png") return ".png"; |
| 647 | if (mimeType === "image/webp") return ".webp"; |
no outgoing calls
no test coverage detected