-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use FromFiles and FromForm in same request #248
Comments
Hi @nico-vromans! @post("/upload_files_with_additional_data")
async def upload(self, request) -> Response:
data = await request.multipart()
print(data)
return self.text("OK") This returns a list of parts from the multi part request, with files and input. It's a lower level code API, though, closer to the shape of the message sent by browsers. I will fix this bug as soon as possible, I think I already know what needs to be changed. |
@RobertoPrevato, thanks for the quick reply. I've tested this "workaround" myself and it works beautifully. 👍🏻 |
I'm glad I could help. 🎉 These days I am working on a plugin for MkDocs to generate automatically human readable documentation from OpenAPI Documentation, so I have limited time for the web framework, but a fix will come soon. |
@RobertoPrevato, I'm in no rush and I fully understand having other priorities. Take your time. Good luck with MkDocs, sounds interesting 😉 |
@RobertoPrevato, awesome, thank you 👍🏻 🥳 |
@nico-vromans thank you for reporting this bug! 🎉 I'm still looking into a couple of things, then I'll publish a new version to PyPi with this fix. I have everything automated so I can release at any time to PyPi without issues. |
For some reason, I can't seem to be able to perform both a multi-file upload with additional data on the same form.
Specs:
Here is my html code (simplified):
Here's what I've tried (but didn't work) and what I expect would work:
I've also tried using
FromForm[FormData]
with the followingFormData
:Either I can upload files, without sending additional form data (using only
files: FromFiles
), or I can use the form data without the files (using onlyform: FromForm
). Combining the two doesn't work.When using
async def upload_files_with_additional_data(self, request: Request):
I can get also get the form data from there usingform = await request.form()
, but that only works for additional data, not the files. When I try to upload files I get:I've also tried using
async def upload_files_with_additional_data(self, bytes: FromBytes):
which does seem to contain all the data, but as bytes, and I've tried a few ways to convert these to what I want, but no success there either.Is there a way of uploading both multiple files, alongside other form data (I'm fairly confident there is, but I just haven't figured it out)? If so: how should this be achieved?
The text was updated successfully, but these errors were encountered: