Skip to content

Commit 66b954d

Browse files
committed
fix file block adv mode
1 parent 4169a25 commit 66b954d

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

apps/sim/app/api/tools/mistral/parse/route.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,23 @@ export async function POST(request: NextRequest) {
9292
)
9393
}
9494

95-
const mimeType = userFile.type || 'application/pdf'
95+
let mimeType = userFile.type
96+
if (!mimeType || mimeType === 'application/octet-stream') {
97+
const filename = userFile.name?.toLowerCase() || ''
98+
if (filename.endsWith('.pdf')) {
99+
mimeType = 'application/pdf'
100+
} else if (filename.endsWith('.png')) {
101+
mimeType = 'image/png'
102+
} else if (filename.endsWith('.jpg') || filename.endsWith('.jpeg')) {
103+
mimeType = 'image/jpeg'
104+
} else if (filename.endsWith('.gif')) {
105+
mimeType = 'image/gif'
106+
} else if (filename.endsWith('.webp')) {
107+
mimeType = 'image/webp'
108+
} else {
109+
mimeType = 'application/pdf'
110+
}
111+
}
96112
let base64 = userFile.base64
97113
if (!base64) {
98114
const buffer = await downloadFileFromStorage(userFile, requestId, logger)

apps/sim/blocks/blocks/file.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ export const FileV3Block: BlockConfig<FileParserV3Output> = {
251251
type: 'file_v3',
252252
name: 'File',
253253
description: 'Read and parse multiple files',
254-
longDescription: 'Upload files or reference files from previous blocks to extract text content.',
254+
longDescription:
255+
'Upload files directly or import from external URLs to get UserFile objects for use in other blocks.',
255256
docsLink: 'https://docs.sim.ai/tools/file',
256257
category: 'tools',
257258
bgColor: '#40916C',
@@ -271,11 +272,11 @@ export const FileV3Block: BlockConfig<FileParserV3Output> = {
271272
required: true,
272273
},
273274
{
274-
id: 'fileRef',
275-
title: 'Files',
275+
id: 'fileUrl',
276+
title: 'File URL',
276277
type: 'short-input' as SubBlockType,
277278
canonicalParamId: 'fileInput',
278-
placeholder: 'File reference from previous block',
279+
placeholder: 'https://example.com/document.pdf',
279280
mode: 'advanced',
280281
required: true,
281282
},
@@ -285,7 +286,7 @@ export const FileV3Block: BlockConfig<FileParserV3Output> = {
285286
config: {
286287
tool: () => 'file_parser_v3',
287288
params: (params) => {
288-
const fileInput = params.fileInput ?? params.file ?? params.filePath
289+
const fileInput = params.fileInput ?? params.file ?? params.fileUrl ?? params.filePath
289290
if (!fileInput) {
290291
logger.error('No file input provided')
291292
throw new Error('File input is required')
@@ -337,7 +338,9 @@ export const FileV3Block: BlockConfig<FileParserV3Output> = {
337338
},
338339
},
339340
inputs: {
340-
fileInput: { type: 'json', description: 'File input (upload or UserFile reference)' },
341+
fileInput: { type: 'json', description: 'File input (upload or URL)' },
342+
fileUrl: { type: 'string', description: 'External file URL (advanced mode)' },
343+
file: { type: 'json', description: 'Uploaded file data (basic mode)' },
341344
fileType: { type: 'string', description: 'File type' },
342345
},
343346
outputs: {

0 commit comments

Comments
 (0)