"""文件接口 DTO。""" from __future__ import annotations from datetime import datetime from pydantic import BaseModel, Field class UploadedFileOut(BaseModel): id: int storage_path: str original_filename: str content_type: str size_bytes: int sha256: str source: str uploaded_by: str uploaded_at: datetime model_config = {"from_attributes": True} class FileUploadResponse(BaseModel): id: int = Field(..., description="新写入的数据库行 ID") filename: str = Field(..., description="客户端原始文件名") size_bytes: int sha256: str storage_path: str uploaded_at: datetime class FileListResponse(BaseModel): total: int items: list[UploadedFileOut] class SftpRegisterRequest(BaseModel): """登记一个通过 SFTP 上传到 ``incoming/`` 下的文件。""" filename: str = Field( ..., description="文件在 SFTP chroot 下的相对路径,必须落在 incoming/ 之下,例如 incoming/abc.bin", ) original_filename: str = Field(..., description="客户端原始文件名") uploaded_by: str = Field(default="sftp", description="登记者标识,写入 uploaded_by 字段")