File tree Expand file tree Collapse file tree
apps/sim/app/api/files/upload Expand file tree Collapse file tree Original file line number Diff line number Diff 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' ) {
You can’t perform that action at this time.
0 commit comments