Skip to content

Temp & promote ​

Version: 1.5
Date: 2026-11-23
Status: Working baseline

Temp (BF-001) ​

  1. Authorize caller
  2. Validate ext/MIME/size (defaults OPEN)
  3. Mint tmp_id + storage_name ({uuidv7}.{ext})
  4. Insert temp_uploads (+ optional workspace_id)
  5. Ghi {FS_TEMP_ROOT}/{storage_name}
  6. Trả tmp_id khi ready

TTL: created_at + parse(temp.ttl) — không cột expires_at.
GC temp: E.03.

Promote (BF-002) ​

  1. Authorize + load temp; kiểm TTL
  2. Mint file_id; giữ storage_name; build storage_key
  3. Move bytes temp → {FS_LOCAL_ROOT}/{storage_key}
  4. Nếu video (DEC-014/015): thử ffmpeg cover theo video.cover.* (random seek + max attempts); success → ghi cover + set cover_storage_name; fail hết retry → vẫn promote, cover_storage_name = null (Q-BR-057)
  5. Insert files (storage_tier=local, copy workspace_id; cover_storage_name nullable)
  6. Đánh dấu temp promoted (promoted_file_id)
  7. Response đồng bộ tối thiểu gồm file_id — không API cover riêng

Không chạy migrate trong request promote. Job local→cloud chỉ chạy sau (async, local.migrate_cron) — xem E.03.

OPEN: cùng uploader? (Q-BR-012); giữ/xóa row temp sau promote (Q-BR-034).
GC temp (BF-007): unlink → DELETE row — không status=purged (Owner 2026-11-23); xem E.03.

platform-file/docs = SoT chi tiết File Service · hub platform-docs giữ overview + ref