MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / normalizeDownloadedMedia

Function normalizeDownloadedMedia

ai/ai.ts:629–644  ·  view source on GitHub ↗
(
  downloaded: any,
)

Source from the content-addressed store, hash-verified

627
628const 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
645const getImageExtensionForMime = (mimeType: string): string => {
646 if (mimeType === "image/png") return ".png";
647 if (mimeType === "image/webp") return ".webp";

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected