@@ -13,7 +13,7 @@ import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
1313import { captureServerEvent } from '@/lib/posthog/server'
1414import type { StorageContext } from '@/lib/uploads/config'
1515import { 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'
1717import {
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