mirror of
https://github.com/coder/coder.git
synced 2026-06-03 21:18:24 +00:00
a104d608a3
This change adds support for image attachments to chat via add button and clipboard paste. Files are stored in a new `chat_files` table and referenced by ID in message content. File data is resolved from storage at LLM dispatch time, keeping the message content column small. Upload validates MIME types via content type or content sniffing against an allowlist (png, jpeg, gif, webp). The retrieval endpoint serves files with immutable caching headers. On the frontend, uploads start eagerly on attach with a background fetch to pre-warm the browser HTTP cache so the timeline renders instantly after send.
14 lines
356 B
SQL
14 lines
356 B
SQL
INSERT INTO chat_files (id, owner_id, organization_id, created_at, name, mimetype, data)
|
|
SELECT
|
|
'00000000-0000-0000-0000-000000000099',
|
|
u.id,
|
|
om.organization_id,
|
|
'2024-01-01 00:00:00+00',
|
|
'test.png',
|
|
'image/png',
|
|
E'\\x89504E47'
|
|
FROM users u
|
|
JOIN organization_members om ON om.user_id = u.id
|
|
ORDER BY u.created_at, u.id
|
|
LIMIT 1;
|