Skip to content

Commit

Permalink
bugfix: multipart uploads now work
Browse files Browse the repository at this point in the history
This makes multi-part post requests work in cases where one or more files are
being sent with the graphql query.
  • Loading branch information
ayys committed Jan 12, 2024
1 parent 08b676f commit 3b0df43
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions graphql_server/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,14 @@ def get_post_and_files(body, content_type):
files = {}
parts = MultipartDecoder(body, content_type).parts
for part in parts:
for name, header_value in part.headers.items():
for header_name, header_value in part.headers.items():
value, params = parse_header(header_value)
if name.lower() == "content-disposition":
if header_name.lower() == "content-disposition":
name = params.get("name")
filename = params.get("filename")
if filename:
files[name.decode("utf-8")] = File(
content=part.content, filename=filename
)
files[name] = File(content=part.content, filename=filename)
else:
name = params.get("name")
post[name.decode("utf-8")] = part.content.decode("utf-8")
return post, files

Expand Down

0 comments on commit 3b0df43

Please sign in to comment.