mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-10 07:27:57 -05:00
Fix (#1176)
This commit is contained in:
committed by
GitHub
parent
7d62c200fa
commit
cadfcdbfbd
@@ -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()) {
|
||||
|
||||
@@ -420,6 +420,12 @@ const UserInput = forwardRef<UserInputRef, UserInputProps>(
|
||||
|
||||
// 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<UserInputRef, UserInputProps>(
|
||||
type='file'
|
||||
onChange={handleFileChange}
|
||||
className='hidden'
|
||||
accept='.pdf,.doc,.docx,.txt,.md,.png,.jpg,.jpeg,.gif'
|
||||
accept='image/*'
|
||||
multiple
|
||||
disabled={disabled || isLoading}
|
||||
/>
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user