From 167fed622c47793bf7cfb1d88902a11037bc345d Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Wed, 12 Apr 2023 13:53:18 +0200 Subject: [PATCH] Fix handling of value when multiple files in form-data It appears that the value list extracted from the `FormData` is not necessarily composed of `UploadFile` instances. --- fastapi/dependencies/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index c581348c9..e5c7d777c 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -778,7 +778,10 @@ async def request_body_to_args( async with anyio.create_task_group() as tg: for sub_value in value: - tg.start_soon(process_fn, sub_value.read) + if isinstance(sub_value, UploadFile): + tg.start_soon(process_fn, sub_value.read) + else: + results.append(sub_value) value = sequence_shape_to_type[field.shape](results) v_, errors_ = field.validate(value, values, loc=loc)