-
Notifications
You must be signed in to change notification settings - Fork 15
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
If request.body is a file-like object, send fails #38
Comments
(I ran into this when using the internetarchive library - as discussed here jjjake/internetarchive#550) Otherwise the library mostly seems to work, so that's great. |
@koenvo - do you have any opinion on what is the right fix for this? |
Hi! Sorry for the late reply. As your solution follows the behavior of requests (because it works), it looks like a good solution for now. When people like to do streaming uploads another solution is required. But at this moment there doesn’t seem to be a blocking streaming solution possible. XMLHttpRequest can’t do streaming upload and fetch isn’t blocking. Are you able and willing to create a PR for this? |
Sure thing, I'll do that today, thanks for the reply. |
hi @MerlijnWajer, do you need any help with this? |
If request.body is a file(-like) interface, read the full contents and then send it. See koenvo#38
Just made the pull request, sorry for the extreme delay, I was very busy. |
When using the python requests library, if one sets the body (data) to a file-like object, such as io.BytesIO or io.StringIO, the body becomes something like
<_io.BytesIO object at 0x1550d50>
when using pyodide-http, as opposed to the actual contents of the file-like object.Below is a very hacky fix for this problem:
I suppose that perhaps a stream method could be used with a file-like object? Any ideas on how to best solve this problem?
The text was updated successfully, but these errors were encountered: