"""The shape an upload answers with.""" from pydantic import BaseModel, Field class ImageRead(BaseModel): """One stored image, as the client needs to know about it. The caller gets the URL *and* the Markdown that embeds it, because those are the two things it needs and only one of them is pleasant to assemble by hand. They are produced together here so a client cannot invent a slightly different syntax than the one the reader parses. """ key: str = Field(description="对象在桶里的键,也是这个 URL 的唯一来源") url: str = Field(description="句子里的图片地址(同源相对路径,如 /api/images/…)") markdown: str = Field(description="可直接粘进句子的 Markdown:![图注](地址)") content_type: str = Field(description="识别出来的图片类型,如 image/png") size: int = Field(description="字节数") sha256: str = Field(description="内容的 SHA-256,键就是它的一部分")