Skip to content

Commit b92a51b

Browse files
waleedlatif1claude
andcommitted
fix(files): resolve content type for image-only contexts when MIME is generic
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d2dcf3f commit b92a51b

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

apps/sim/app/api/files/upload/route.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
1313
import { captureServerEvent } from '@/lib/posthog/server'
1414
import type { StorageContext } from '@/lib/uploads/config'
1515
import { generateWorkspaceFileKey } from '@/lib/uploads/contexts/workspace/workspace-file-manager'
16-
import { isImageFileType } from '@/lib/uploads/utils/file-utils'
16+
import { isImageFileType, resolveFileType } from '@/lib/uploads/utils/file-utils'
1717
import {
1818
SUPPORTED_AUDIO_EXTENSIONS,
1919
SUPPORTED_CODE_EXTENSIONS,
@@ -350,6 +350,8 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
350350

351351
logger.info(`Uploading ${context} file: ${originalName}`)
352352

353+
const resolvedContentType = resolveFileType({ type: file.type, name: originalName })
354+
353355
const timestamp = Date.now()
354356
const safeFileName = sanitizeFileName(originalName)
355357
const storageKey = `${context}/${timestamp}-${safeFileName}`
@@ -368,7 +370,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
368370
const fileInfo = await storageService.uploadFile({
369371
file: buffer,
370372
fileName: storageKey,
371-
contentType: file.type,
373+
contentType: resolvedContentType,
372374
context,
373375
preserveKey: true,
374376
customKey: storageKey,
@@ -385,7 +387,7 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
385387
key: fileInfo.key,
386388
name: originalName,
387389
size: buffer.length,
388-
type: file.type,
390+
type: resolvedContentType,
389391
},
390392
directUploadSupported: false,
391393
}

0 commit comments

Comments
 (0)