Fix AI mime-type and enable invoice actions
This commit is contained in:
@@ -67,12 +67,19 @@ export class GeminiExtractorService {
|
||||
Pay close attention to Jordanian Tax Rules (subtotal - discount + tax = grand_total).
|
||||
`;
|
||||
|
||||
// Detect MIME type based on extension
|
||||
const ext = path.extname(filePath).toLowerCase();
|
||||
let mimeType = 'image/jpeg';
|
||||
if (ext === '.pdf') mimeType = 'application/pdf';
|
||||
else if (ext === '.png') mimeType = 'image/png';
|
||||
else if (ext === '.webp') mimeType = 'image/webp';
|
||||
|
||||
const result = await this.model.generateContent([
|
||||
prompt,
|
||||
{
|
||||
inlineData: {
|
||||
data: fileData.toString('base64'),
|
||||
mimeType: 'image/jpeg', // Adjusted based on file extension in prod
|
||||
mimeType: mimeType,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user