Добавить прямую загрузку по короткой подписи.

Proxy endpoint сохранён. Complete сверяет владельца, размер и checksum, а сравнение трафика API на двух размерах лежит в evidence.
This commit is contained in:
2026-11-09 00:36:52 +03:00
parent 8faf08d8eb
commit 4654de5837
18 changed files with 812 additions and 11 deletions
+22
View File
@@ -0,0 +1,22 @@
-- Optional presigned upload. The signed URL dies quickly. The row stays pending
-- until complete checks the object that actually landed in the bucket.
-- Incomplete rows are aborted by the same grace sweeper as other uncommitted keys.
CREATE TABLE direct_uploads (
id UUID PRIMARY KEY,
chat_id UUID NOT NULL REFERENCES chats (id) ON DELETE CASCADE,
owner_id UUID NOT NULL REFERENCES users (id),
filename TEXT NOT NULL,
content_type TEXT NOT NULL,
size_bytes INTEGER NOT NULL,
object_key TEXT NOT NULL UNIQUE,
status TEXT NOT NULL,
expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT direct_uploads_filename_len CHECK (char_length(filename) BETWEEN 1 AND 255),
CONSTRAINT direct_uploads_size CHECK (size_bytes BETWEEN 1 AND 10485760),
CONSTRAINT direct_uploads_type CHECK (content_type IN ('image/png', 'image/jpeg')),
CONSTRAINT direct_uploads_status CHECK (status IN ('pending', 'completed', 'aborted'))
);
CREATE INDEX direct_uploads_pending_idx ON direct_uploads (expires_at) WHERE status = 'pending';