Skip to content
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

Streaming upload with StreamReader as data is not working #2793

Closed
Shivelight opened this issue Mar 4, 2018 · 5 comments
Closed

Streaming upload with StreamReader as data is not working #2793

Shivelight opened this issue Mar 4, 2018 · 5 comments
Labels

Comments

@Shivelight
Copy link

Long story short

I'm trying to re-upload images by chaining get and post requests as explained in the docs but it doesn't work.
https://docs.aiohttp.org/en/latest/client_quickstart.html#streaming-uploads

Expected behaviour

I'm not sure, is this expected behavior?

Actual behaviour

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 372, in update_body_from_data
    body = payload.PAYLOAD_REGISTRY.get(body, disposition=None)
  File "/usr/lib/python3.6/site-packages/aiohttp/payload.py", line 62, in get
    raise LookupError()
aiohttp.payload.LookupError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "<stdin>", line 4, in main
  File "/usr/lib/python3.6/site-packages/aiohttp/client.py", line 312, in _request
    ssl=ssl, proxy_headers=proxy_headers)
  File "/usr/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 208, in __init__
    self.update_body_from_data(data)
  File "/usr/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 374, in update_body_from_data
    body = FormData(body)()
  File "/usr/lib/python3.6/site-packages/aiohttp/formdata.py", line 28, in __init__
    self.add_fields(*fields)
  File "/usr/lib/python3.6/site-packages/aiohttp/formdata.py", line 90, in add_fields
    .format(rec))
TypeError: Only io.IOBase, multidict and (name, file) pairs allowed, use .add_field() for passing more complex parameters, got <StreamReader 2138 bytes>

Steps to reproduce

Just run the last example code of streaming upload section.

Your environment

Arch Linux, Python 3.6.4, aiohttp 3.0.5

@asvetlov
Copy link
Member

asvetlov commented Mar 6, 2018

StreamReader is not supported anymore, sorry.

Documentation should be updated.

@Shivelight
Copy link
Author

I'll use the streamer decorator instead. Thanks for the clarify!

@asvetlov
Copy link
Member

asvetlov commented Mar 6, 2018

Welcome!

@asvetlov
Copy link
Member

As of #2802 you can pass .content again.

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants