From 211bdb03f6b20f7dc90fe0037e57cd142c48deb5 Mon Sep 17 00:00:00 2001 From: Robbe Sneyders Date: Tue, 13 Feb 2024 23:52:24 +0100 Subject: [PATCH] Fix file upload for base64 encoded files (#1843) Fixes #1825 Files can be encoded as bytes or base64 ([openapi docs](https://swagger.io/docs/specification/describing-request-body/file-upload/)), we were only handling bytes before. --- connexion/validators/form_data.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/connexion/validators/form_data.py b/connexion/validators/form_data.py index 6c68c48eb..6e7360d60 100644 --- a/connexion/validators/form_data.py +++ b/connexion/validators/form_data.py @@ -61,10 +61,10 @@ async def _parse(self, stream: t.AsyncGenerator[bytes, None], scope: Scope) -> d value = data.getlist(key) def is_file(schema): - return ( - schema.get("type") == "string" - and schema.get("format") == "binary" - ) + return schema.get("type") == "string" and schema.get("format") in [ + "binary", + "base64", + ] # Single file upload if is_file(param_schema):