Skip to content

Commit c0554cc

Browse files
committed
added 10mb image size guardrail for chat interface
1 parent e69ef06 commit c0554cc

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/ui/chat-interface.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,18 @@ export default function ChatInterface({
4444

4545
const handleImageUpload = (e: React.ChangeEvent<HTMLInputElement>) => {
4646
const file = e.target.files?.[0];
47-
if (file && onImageUpload) {
48-
onImageUpload(file);
47+
if (file) {
48+
// Check file size (10MB = 10 * 1024 * 1024 bytes)
49+
const maxSize = 10 * 1024 * 1024; // 10MB in bytes
50+
if (file.size > maxSize) {
51+
alert("Image size cannot exceed 10MB. Please choose a smaller image.");
52+
e.target.value = "";
53+
return;
54+
}
55+
56+
if (onImageUpload) {
57+
onImageUpload(file);
58+
}
4959
}
5060
// Reset the input value so the same file can be selected again
5161
e.target.value = "";

0 commit comments

Comments
 (0)