diff --git a/backend/helpers/ivantiApi.js b/backend/helpers/ivantiApi.js index e101423..393c84c 100644 --- a/backend/helpers/ivantiApi.js +++ b/backend/helpers/ivantiApi.js @@ -109,11 +109,11 @@ function ivantiFormPost(urlPath, fields, files, apiKey, skipTls) { } // File fields - for (const { name, buffer, filename } of files) { + for (const { name, buffer, filename, contentType } of files) { parts.push(Buffer.from( `--${boundary}\r\n` + `Content-Disposition: form-data; name="${name}"; filename="${filename}"\r\n` + - `Content-Type: application/octet-stream\r\n\r\n` + `Content-Type: ${contentType || 'application/octet-stream'}\r\n\r\n` )); parts.push(buffer); parts.push(Buffer.from('\r\n')); diff --git a/backend/routes/ivantiFpWorkflow.js b/backend/routes/ivantiFpWorkflow.js index 15fe666..569b780 100644 --- a/backend/routes/ivantiFpWorkflow.js +++ b/backend/routes/ivantiFpWorkflow.js @@ -1048,10 +1048,10 @@ function createIvantiFpWorkflowRouter(db, requireAuth) { console.log('[attachFiles] Uploading', files.length, 'files to', attachUrl); for (const f of files) { - console.log('[attachFiles] Uploading:', f.originalname, 'size:', f.size); + console.log('[attachFiles] Uploading:', f.originalname, 'size:', f.size, 'mimetype:', f.mimetype); try { - // Use ivantiFormPost with field name 'files' (same as create endpoint) - const formFiles = [{ name: 'files', buffer: f.buffer, filename: f.originalname }]; + // Use ivantiFormPost with field name 'file' and proper MIME type + const formFiles = [{ name: 'file', buffer: f.buffer, filename: f.originalname, contentType: f.mimetype || 'application/octet-stream' }]; const result = await ivantiFormPost(attachUrl, [], formFiles, apiKey, skipTls); console.log('[attachFiles] Result for', f.originalname, '— status:', result.status, 'body:', (result.body || '').substring(0, 200)); const success = result.status === 200 || result.status === 201 || result.status === 202;