mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +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.
13 lines
491 B
SQL
13 lines
491 B
SQL
CREATE TABLE chat_files (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
organization_id UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
name TEXT NOT NULL DEFAULT '',
|
|
mimetype TEXT NOT NULL,
|
|
data BYTEA NOT NULL
|
|
);
|
|
|
|
CREATE INDEX idx_chat_files_owner ON chat_files(owner_id);
|
|
CREATE INDEX idx_chat_files_org ON chat_files(organization_id);
|