Skip to content

Commit b72e737

Browse files
committed
feat(files): allow image uploads in workspace files
1 parent 68f66ba commit b72e737

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

apps/sim/app/workspace/[workspaceId]/files/files.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
SUPPORTED_AUDIO_EXTENSIONS,
4444
SUPPORTED_CODE_EXTENSIONS,
4545
SUPPORTED_DOCUMENT_EXTENSIONS,
46+
SUPPORTED_IMAGE_EXTENSIONS,
4647
SUPPORTED_VIDEO_EXTENSIONS,
4748
} from '@/lib/uploads/utils/validation'
4849
import type {
@@ -89,6 +90,7 @@ const SUPPORTED_EXTENSIONS = [
8990
...SUPPORTED_CODE_EXTENSIONS,
9091
...SUPPORTED_AUDIO_EXTENSIONS,
9192
...SUPPORTED_VIDEO_EXTENSIONS,
93+
...SUPPORTED_IMAGE_EXTENSIONS,
9294
] as const
9395

9496
const ACCEPT_ATTR = SUPPORTED_EXTENSIONS.map((ext) => `.${ext}`).join(',')
@@ -125,6 +127,7 @@ function formatFileType(mimeType: string | null, filename: string): string {
125127

126128
if (mimeType?.startsWith('audio/')) return 'Audio'
127129
if (mimeType?.startsWith('video/')) return 'Video'
130+
if (mimeType?.startsWith('image/')) return 'Image'
128131

129132
const ext = getFileExtension(filename)
130133
if (ext) return ext.toUpperCase()

apps/sim/lib/uploads/utils/validation.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,31 @@ export const SUPPORTED_AUDIO_EXTENSIONS = [
9595

9696
export const SUPPORTED_VIDEO_EXTENSIONS = ['mp4', 'mov', 'avi', 'mkv', 'webm'] as const
9797

98+
export const SUPPORTED_IMAGE_EXTENSIONS = [
99+
'png',
100+
'jpg',
101+
'jpeg',
102+
'gif',
103+
'webp',
104+
'svg',
105+
'bmp',
106+
'tif',
107+
'tiff',
108+
'heic',
109+
'heif',
110+
'avif',
111+
'ico',
112+
] as const
113+
98114
export type SupportedDocumentExtension = (typeof SUPPORTED_DOCUMENT_EXTENSIONS)[number]
99115
export type SupportedAudioExtension = (typeof SUPPORTED_AUDIO_EXTENSIONS)[number]
100116
export type SupportedVideoExtension = (typeof SUPPORTED_VIDEO_EXTENSIONS)[number]
117+
export type SupportedImageExtension = (typeof SUPPORTED_IMAGE_EXTENSIONS)[number]
101118
export type SupportedMediaExtension =
102119
| SupportedDocumentExtension
103120
| SupportedAudioExtension
104121
| SupportedVideoExtension
122+
| SupportedImageExtension
105123

106124
export const SUPPORTED_MIME_TYPES: Record<SupportedDocumentExtension, string[]> = {
107125
pdf: ['application/pdf', 'application/x-pdf'],
@@ -180,14 +198,19 @@ const SUPPORTED_IMAGE_MIME_TYPES = [
180198
'image/gif',
181199
'image/webp',
182200
'image/svg+xml',
201+
'image/bmp',
202+
'image/tiff',
203+
'image/heic',
204+
'image/heif',
205+
'image/avif',
206+
'image/x-icon',
207+
'image/vnd.microsoft.icon',
183208
]
184209

185-
const SUPPORTED_IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg']
186-
187210
export const CHAT_ACCEPT_ATTRIBUTE = [
188211
ACCEPT_ATTRIBUTE,
189212
...SUPPORTED_IMAGE_MIME_TYPES,
190-
...SUPPORTED_IMAGE_EXTENSIONS,
213+
...SUPPORTED_IMAGE_EXTENSIONS.map((ext) => `.${ext}`),
191214
].join(',')
192215

193216
export interface FileValidationError {

0 commit comments

Comments
 (0)