diff --git a/apps/sim/app/api/tools/mistral/parse/route.ts b/apps/sim/app/api/tools/mistral/parse/route.ts index f0132228c..f8b0c1191 100644 --- a/apps/sim/app/api/tools/mistral/parse/route.ts +++ b/apps/sim/app/api/tools/mistral/parse/route.ts @@ -92,7 +92,23 @@ export async function POST(request: NextRequest) { ) } - const mimeType = userFile.type || 'application/pdf' + let mimeType = userFile.type + if (!mimeType || mimeType === 'application/octet-stream') { + const filename = userFile.name?.toLowerCase() || '' + if (filename.endsWith('.pdf')) { + mimeType = 'application/pdf' + } else if (filename.endsWith('.png')) { + mimeType = 'image/png' + } else if (filename.endsWith('.jpg') || filename.endsWith('.jpeg')) { + mimeType = 'image/jpeg' + } else if (filename.endsWith('.gif')) { + mimeType = 'image/gif' + } else if (filename.endsWith('.webp')) { + mimeType = 'image/webp' + } else { + mimeType = 'application/pdf' + } + } let base64 = userFile.base64 if (!base64) { const buffer = await downloadFileFromStorage(userFile, requestId, logger) diff --git a/apps/sim/blocks/blocks/file.ts b/apps/sim/blocks/blocks/file.ts index 521b74e92..3b0f5ccb9 100644 --- a/apps/sim/blocks/blocks/file.ts +++ b/apps/sim/blocks/blocks/file.ts @@ -251,7 +251,8 @@ export const FileV3Block: BlockConfig = { type: 'file_v3', name: 'File', description: 'Read and parse multiple files', - longDescription: 'Upload files or reference files from previous blocks to extract text content.', + longDescription: + 'Upload files directly or import from external URLs to get UserFile objects for use in other blocks.', docsLink: 'https://docs.sim.ai/tools/file', category: 'tools', bgColor: '#40916C', @@ -271,11 +272,11 @@ export const FileV3Block: BlockConfig = { required: true, }, { - id: 'fileRef', - title: 'Files', + id: 'fileUrl', + title: 'File URL', type: 'short-input' as SubBlockType, canonicalParamId: 'fileInput', - placeholder: 'File reference from previous block', + placeholder: 'https://example.com/document.pdf', mode: 'advanced', required: true, }, @@ -285,7 +286,7 @@ export const FileV3Block: BlockConfig = { config: { tool: () => 'file_parser_v3', params: (params) => { - const fileInput = params.fileInput ?? params.file ?? params.filePath + const fileInput = params.fileInput ?? params.file ?? params.fileUrl ?? params.filePath if (!fileInput) { logger.error('No file input provided') throw new Error('File input is required') @@ -337,7 +338,9 @@ export const FileV3Block: BlockConfig = { }, }, inputs: { - fileInput: { type: 'json', description: 'File input (upload or UserFile reference)' }, + fileInput: { type: 'json', description: 'File input (upload or URL)' }, + fileUrl: { type: 'string', description: 'External file URL (advanced mode)' }, + file: { type: 'json', description: 'Uploaded file data (basic mode)' }, fileType: { type: 'string', description: 'File type' }, }, outputs: {