Skip to content

Commit cadfcdb

Browse files
authored
Fix (#1176)
1 parent 7d62c20 commit cadfcdb

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { v4 as uuidv4 } from 'uuid'
55
import { getSession } from '@/lib/auth'
66
import { createLogger } from '@/lib/logs/console/logger'
77
import { getStorageProvider, isUsingCloudStorage } from '@/lib/uploads'
8+
import { isImageFileType } from '@/lib/uploads/file-utils'
89
// Dynamic imports for storage clients to avoid client-side bundling
910
import {
1011
BLOB_CHAT_CONFIG,
@@ -112,6 +113,12 @@ export async function POST(request: NextRequest) {
112113
if (!sessionUserId?.trim()) {
113114
throw new ValidationError('Authenticated user session is required for copilot uploads')
114115
}
116+
// Only allow image uploads for copilot
117+
if (!isImageFileType(contentType)) {
118+
throw new ValidationError(
119+
'Only image files (JPEG, PNG, GIF, WebP, SVG) are allowed for copilot uploads'
120+
)
121+
}
115122
}
116123

117124
if (!isUsingCloudStorage()) {

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/copilot/components/user-input/user-input.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,12 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
420420

421421
// Process files one by one
422422
for (const file of Array.from(fileList)) {
423+
// Only accept image files
424+
if (!file.type.startsWith('image/')) {
425+
logger.warn(`File ${file.name} is not an image. Only image files are allowed.`)
426+
continue
427+
}
428+
423429
// Create a preview URL for images
424430
let previewUrl: string | undefined
425431
if (file.type.startsWith('image/')) {
@@ -2526,7 +2532,7 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
25262532
type='file'
25272533
onChange={handleFileChange}
25282534
className='hidden'
2529-
accept='.pdf,.doc,.docx,.txt,.md,.png,.jpg,.jpeg,.gif'
2535+
accept='image/*'
25302536
multiple
25312537
disabled={disabled || isLoading}
25322538
/>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const SIM_AGENT_API_URL_DEFAULT = 'https://staging.agent.sim.ai'
1+
export const SIM_AGENT_API_URL_DEFAULT = 'https://agent.sim.ai'

apps/sim/lib/uploads/file-utils.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ export function isSupportedFileType(mimeType: string): boolean {
6060
return mimeType.toLowerCase() in MIME_TYPE_MAPPING
6161
}
6262

63+
/**
64+
* Check if a MIME type is an image type (for copilot uploads)
65+
*/
66+
export function isImageFileType(mimeType: string): boolean {
67+
const imageTypes = [
68+
'image/jpeg',
69+
'image/jpg',
70+
'image/png',
71+
'image/gif',
72+
'image/webp',
73+
'image/svg+xml',
74+
]
75+
return imageTypes.includes(mimeType.toLowerCase())
76+
}
77+
6378
/**
6479
* Convert a file buffer to base64
6580
*/

0 commit comments

Comments
 (0)