with open("flower.jpg", "rb") as f:
data = f.read()
with httpx.Client() as client:
client.post("http://localhost:8000/", files={"data": data})
Traceback (most recent call last):
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/middleware/exceptions.py", line 49, in __call__
await self.app(scope, receive, send)
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/routes/http.py", line 72, in handle
response = await self._get_response_for_request(
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/routes/http.py", line 116, in _get_response_for_request
response = await self._call_handler_function(
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/routes/http.py", line 144, in _call_handler_function
response_data = await self._get_response_data(
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/routes/http.py", line 168, in _get_response_data
kwargs["data"] = await request_data
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/kwargs.py", line 540, in _get_request_data
form_data = await request.form()
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite/connection/request.py", line 140, in form
form_values = await parser()
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite_multipart/parser.py", line 84, in __call__
parse_result.extend(await self._parse_chunk())
File "/home/mitch/uni/starlite-multipart-error/.venv/lib/python3.9/site-packages/starlite_multipart/parser.py", line 65, in _parse_chunk
items.append((field_name, data.decode(self.charset)))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xad in position 2: invalid start byte
Minimal reproducible example on this repo.
When posting a photo to a route with an UploadFile parameter, an exception is thrown: