diff --git a/apps/sim/app/api/files/presigned/route.ts b/apps/sim/app/api/files/presigned/route.ts index 496e7ab6f3..98f58315c6 100644 --- a/apps/sim/app/api/files/presigned/route.ts +++ b/apps/sim/app/api/files/presigned/route.ts @@ -5,6 +5,7 @@ import { v4 as uuidv4 } from 'uuid' import { getSession } from '@/lib/auth' import { createLogger } from '@/lib/logs/console/logger' import { getStorageProvider, isUsingCloudStorage } from '@/lib/uploads' +import { isImageFileType } from '@/lib/uploads/file-utils' // Dynamic imports for storage clients to avoid client-side bundling import { BLOB_CHAT_CONFIG, @@ -112,6 +113,12 @@ export async function POST(request: NextRequest) { if (!sessionUserId?.trim()) { throw new ValidationError('Authenticated user session is required for copilot uploads') } + // Only allow image uploads for copilot + if (!isImageFileType(contentType)) { + throw new ValidationError( + 'Only image files (JPEG, PNG, GIF, WebP, SVG) are allowed for copilot uploads' + ) + } } if (!isUsingCloudStorage()) { diff --git a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx index a2f53a6b81..37c9550eb4 100644 --- a/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx +++ b/apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx @@ -420,6 +420,12 @@ const UserInput = forwardRef( // Process files one by one for (const file of Array.from(fileList)) { + // Only accept image files + if (!file.type.startsWith('image/')) { + logger.warn(`File ${file.name} is not an image. Only image files are allowed.`) + continue + } + // Create a preview URL for images let previewUrl: string | undefined if (file.type.startsWith('image/')) { @@ -2526,7 +2532,7 @@ const UserInput = forwardRef( type='file' onChange={handleFileChange} className='hidden' - accept='.pdf,.doc,.docx,.txt,.md,.png,.jpg,.jpeg,.gif' + accept='image/*' multiple disabled={disabled || isLoading} /> diff --git a/apps/sim/lib/sim-agent/constants.ts b/apps/sim/lib/sim-agent/constants.ts index 1997402e4d..41ee3900c5 100644 --- a/apps/sim/lib/sim-agent/constants.ts +++ b/apps/sim/lib/sim-agent/constants.ts @@ -1 +1 @@ -export const SIM_AGENT_API_URL_DEFAULT = 'https://staging.agent.sim.ai' +export const SIM_AGENT_API_URL_DEFAULT = 'https://agent.sim.ai' diff --git a/apps/sim/lib/uploads/file-utils.ts b/apps/sim/lib/uploads/file-utils.ts index 188354e57a..a924fbacc5 100644 --- a/apps/sim/lib/uploads/file-utils.ts +++ b/apps/sim/lib/uploads/file-utils.ts @@ -60,6 +60,21 @@ export function isSupportedFileType(mimeType: string): boolean { return mimeType.toLowerCase() in MIME_TYPE_MAPPING } +/** + * Check if a MIME type is an image type (for copilot uploads) + */ +export function isImageFileType(mimeType: string): boolean { + const imageTypes = [ + 'image/jpeg', + 'image/jpg', + 'image/png', + 'image/gif', + 'image/webp', + 'image/svg+xml', + ] + return imageTypes.includes(mimeType.toLowerCase()) +} + /** * Convert a file buffer to base64 */