| 12345678910111213141516171819 |
- export function buildUploadedDocumentPayload(file) {
- if (!file || typeof file.content !== 'string' || !file.content.trim()) {
- return null
- }
- const normalizedType = String(file.type || file.fileType || '')
- .replace(/^\./, '')
- .toLowerCase()
- return {
- file_name: file.name || file.fileName || '',
- file_type: normalizedType,
- content: file.content,
- attachment_id: file.attachmentId || file.attachment_id || '',
- char_count: Number.isFinite(Number(file.charCount ?? file.char_count))
- ? Number(file.charCount ?? file.char_count)
- : file.content.length
- }
- }
|