-
Hi. Is there any way to define handler that accept request body of "application/octet-stream" type? I tried async def flash_firmware(self, data: Annotated[UploadFile, Body(media_type='application/octet-stream')]) -> FirmwareUploadResponse and async def flash_firmware(self, data: Annotated[bytes, Body(media_type='application/octet-stream')]) -> FirmwareUploadResponse But always get The reason I want this feature is to implement OTA firmware update for ESP32 chip. Due to limit of RAM, I cannot afford any deserializtion, nor validation feature, and can only expect the client to upload proper binary file. The Python code here is to make a mock server for developing web frontend. The actual backend code will be in Rust, based on ESP-IDF framework. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Can you post a full example of your code with the first example? That should work afaik. Anyway, if you don't want all validation, you'll have to skip injecting the body via the async def flash_firmware(request: Request) -> FirmwareUploadResponse:
body = await request.body() |
Beta Was this translation helpful? Give feedback.
to add to this, you can directly have
body
injected as mentioned here https://docs.litestar.dev/latest/usage/routing/handlers.html#reserved-keyword-arguments