Skip to content

Commit

Permalink
Fix file upload for base64 encoded files (#1843)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RobbeSneyders authored Feb 13, 2024
1 parent 5de6dcc commit 211bdb0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions connexion/validators/form_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 211bdb0

Please sign in to comment.