Skip to content

Streaming upload with StreamReader as data is not working #2793

Closed
@Shivelight

Description

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions