/** * Best-effort MIME type inference from a file path's extension. * * Used to label outbound attachments (Gmail/Outlook multipart parts, native * email attachments) when the source is a local file with no declared type. */ import { extname } from "node:path"; const MIME_MAP: Record = { ".pdf": "application/pdf", ".zip": "application/zip", ".gz": "application/gzip", ".tar": "application/x-tar", ".doc": "application/msword", ".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", ".xls": "application/vnd.ms-excel", ".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ".ppt": "application/vnd.ms-powerpoint", ".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", ".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".svg": "image/svg+xml", ".webp": "image/webp", ".mp3": "audio/mpeg", ".mp4": "video/mp4", ".wav": "audio/wav", ".txt": "text/plain", ".html": "text/html", ".css": "text/css", ".js": "text/javascript", ".json": "application/json", ".xml": "application/xml", ".csv": "text/csv", }; export function guessMimeType(filePath: string): string { return ( MIME_MAP[extname(filePath).toLowerCase()] ?? "application/octet-stream" ); }