Skip to content

Commit 7377716

Browse files
waleedlatif1claude
andcommitted
fix(files): fall back to extension when MIME is generic for image-only uploads
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 09618ed commit 7377716

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,17 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
304304
context === 'profile-pictures' ||
305305
context === 'workspace-logos'
306306
) {
307-
if (context !== 'copilot' && !isImageFileType(file.type)) {
308-
throw new InvalidRequestError(`Only image files are allowed for ${context} uploads`)
307+
if (context !== 'copilot') {
308+
const mimeType = file.type
309+
const isGenericMime = !mimeType || mimeType === 'application/octet-stream'
310+
const extension = originalName.split('.').pop()?.toLowerCase() ?? ''
311+
const extensionIsImage = (SUPPORTED_IMAGE_EXTENSIONS as readonly string[]).includes(
312+
extension
313+
)
314+
const isImage = isGenericMime ? extensionIsImage : isImageFileType(mimeType)
315+
if (!isImage) {
316+
throw new InvalidRequestError(`Only image files are allowed for ${context} uploads`)
317+
}
309318
}
310319

311320
if (context === 'workspace-logos') {

0 commit comments

Comments
 (0)