You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, not sure was the problem was exactly, but going to close this as resolved for now. If there's anything unclear/missing in the docs relative to your problem, feel free to ping back here! Thanks.
It seems to me the OP's problem was the same I'm facing right now in that I'm trying to replicate what is described in the requests docs here: https://2.python-requests.org/en/master/user/advanced/#post-multiple-multipart-encoded-files
The httpx docs @j178 pointed to only seem to describe posting a single file (which works exactly as for requests). However, once multiple files need to be uploaded, requests stops taking a dict and uses a list instead, as a dict can't use the same key multiple times.
The question now would be how, if at all, this behavior of the requests library could be replicated in httpx.
Hi, not sure was the problem was exactly, but going to close this as resolved for now. If there's anything unclear/missing in the docs relative to your problem, feel free to ping back here! Thanks.
@ysq1222 Reopened, I think it’s clearer now what this is about: uploading multiple files for a given POST field using HTTPX (we only support 1 file per file right now).
That last link is particularly helpful, especially because it shows what the API should look like for such a feature, i.e. a list of file dicts (which is a reasonable API I guess, even though the typing for files is already quite involved).
Since it’s supported by Requests I don’t see why we shouldn’t support it. :)
At this point, I imagine any PRs towards resolving this are much welcome? 😄
@ysq1222 Reopened, I think it’s clearer now what this is about: uploading multiple files for a given POST field using HTTPX (we only support 1 file per file right now).
That last link is particularly helpful, especially because it shows what the API should look like for such a feature, i.e. a list of file dicts (which is a reasonable API I guess, even though the typing for files is already quite involved).
Since it’s supported by Requests I don’t see why we shouldn’t support it. :)
At this point, I imagine any PRs towards resolving this are much welcome?
Is there any other site similar to httpbin.org?
I made some changes and they didn't appear to be working. Tested everything and then realized that httpbin.org is not sending the right response. When adding multiple files to the same input, it just sends back the first filename. Checked the same with requests as given in the last link by @ysq1222 and got the same result. Just the name of the first file.
Activity
j178 commentedon Jan 18, 2020
You should read the manual https://www.python-httpx.org/advanced/#multipart-file-encoding
florimondmanca commentedon Jan 20, 2020
Hi, not sure was the problem was exactly, but going to close this as resolved for now. If there's anything unclear/missing in the docs relative to your problem, feel free to ping back here! Thanks.
ChristianMertes commentedon Feb 3, 2020
It seems to me the OP's problem was the same I'm facing right now in that I'm trying to replicate what is described in the
requestsdocs here: https://2.python-requests.org/en/master/user/advanced/#post-multiple-multipart-encoded-filesThe
httpxdocs @j178 pointed to only seem to describe posting a single file (which works exactly as forrequests). However, once multiple files need to be uploaded,requestsstops taking adictand uses alistinstead, as adictcan't use the same key multiple times.The question now would be how, if at all, this behavior of the
requestslibrary could be replicated inhttpx.ysq1222 commentedon Feb 11, 2020
Upload multiple files at once, not one.Can't HTTPX solve it?
ysq1222 commentedon Feb 11, 2020
Upload multiple files at once, not one.Can't HTTPX solve it?
The problem is not solved, why is it closed?
Just like requests: https://2.python-requests.org/en/master/user/advanced/#post-multiple-multipart-encoded-files
florimondmanca commentedon Feb 11, 2020
@ysq1222 Reopened, I think it’s clearer now what this is about: uploading multiple files for a given POST field using HTTPX (we only support 1 file per file right now).
That last link is particularly helpful, especially because it shows what the API should look like for such a feature, i.e. a list of file dicts (which is a reasonable API I guess, even though the typing for
filesis already quite involved).Since it’s supported by Requests I don’t see why we shouldn’t support it. :)
At this point, I imagine any PRs towards resolving this are much welcome? 😄
[-]httpx Can't upload multiple files?[/-][+]Support for multiple files per POST field[/+]florimondmanca commentedon Feb 11, 2020
Edited the issue description to better reflect the need here. 👍
lovelydinosaur commentedon Feb 11, 2020
So, I think we also want to support the "either a dict, or a two-tuple of items" for the
data=...case too.Ie, this works in requests, but not in httpx...
In both cases we want to change how we iterate over the items in
data/files...httpx/httpx/_content_streams.py
Line 293 in b3db9ff
Eg...
ChristianMertes commentedon Feb 11, 2020
Thanks! Great to see quick progress here now :D
You're welcome! Oh. Wait. 😉
ysq1222 commentedon Feb 11, 2020
Will it be supported in the next version?
tegkhanna commentedon Mar 30, 2020
Can someone point me where to look in the codebase if tackling this issue?
florimondmanca commentedon Mar 30, 2020
Hi @tegkhanna 👋 you can look at
MultipartStreamin._content_streams.py. There should be various hints upper in this thread too.tegkhanna commentedon Mar 30, 2020
Thanks @florimondmanca! I will get to it straight away!
tegkhanna commentedon Mar 31, 2020
Is there any other site similar to httpbin.org?
I made some changes and they didn't appear to be working. Tested everything and then realized that httpbin.org is not sending the right response. When adding multiple files to the same input, it just sends back the first filename. Checked the same with
requestsas given in the last link by @ysq1222 and got the same result. Just the name of the first file.tegkhanna commentedon Mar 31, 2020
Nevermind. Checked using https://ptsv2.com/ and it worked like a charm!
Should I add support for this as well as mentioned by @tomchristie?
tegkhanna commentedon Mar 31, 2020
Added a pull request:
#891