(files: { size: number }[])
| 31 | } |
| 32 | |
| 33 | export function assertAttachmentBudget(files: { size: number }[]) { |
| 34 | const total = files.reduce((sum, file) => sum + file.size, 0) |
| 35 | if (total <= MAX_ATTACHMENT_BYTES) return |
| 36 | throw new Error(`Selected attachments exceed the ${MAX_ATTACHMENT_BYTES / 1024 / 1024} MB limit`) |
| 37 | } |
| 38 | |
| 39 | export async function readAttachment(filePath: string, maxBytes = MAX_ATTACHMENT_BYTES) { |
| 40 | const file = await open(filePath, "r") |
no outgoing calls
no test coverage detected