( attachment: Omit<PreparedProviderAttachment, 'providerMimeType' | 'dataUrl' | 'text'>, provider: AttachmentProvider, providerId: ProviderId | string )
| 316 | } |
| 317 | |
| 318 | function validateProviderSupport( |
| 319 | attachment: Omit<PreparedProviderAttachment, 'providerMimeType' | 'dataUrl' | 'text'>, |
| 320 | provider: AttachmentProvider, |
| 321 | providerId: ProviderId | string |
| 322 | ) { |
| 323 | const { filename, mimeType, contentType, extension } = attachment |
| 324 | const supportedLabel = PROVIDER_SUPPORTED_LABELS[provider] |
| 325 | |
| 326 | const supported = isMimeTypeSupportedByProvider(provider, mimeType, contentType, extension) |
| 327 | |
| 328 | if (!supported) { |
| 329 | throw new Error( |
| 330 | `File "${filename}" has MIME type "${mimeType}", which is not supported by provider "${providerId}". Supported attachments: ${supportedLabel}.` |
| 331 | ) |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | export function prepareProviderAttachments( |
| 336 | files: UserFile[] | undefined, |
no test coverage detected