When defining an UploadFile
as Optional
the upload file button disappears.
Removing the Optional
makes the button to be present but there's no way not to specify the file anymore as there's no send empty value
checkbox in this case.
from typing import Annotated, Optional
from pydantic import BaseModel, ConfigDict
from litestar.datastructures import UploadFile
from litestar.enums import RequestEncodingType
from litestar.params import Body
class FormData(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
file: Optional[UploadFile]
some_params: dict
@post("/test")
async def handle_file(data: Annotated[FormData, Body(media_type=RequestEncodingType.MULTI_PART)]) -> None:
print(data.file)
app = Litestar(route_handlers=[handle_file])
2.8.2
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too