Viewing File: /opt/alt/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/payload_streamer.cpython-35.pyc
Z @ s d Z d d l Z d d l m Z m Z d
Z Gd d d Z Gd d d Z e e Gd d
d
e Z e e Gd d d e Z d S)al Payload implemenation for coroutines as data provider.
As a simple case, you can upload data from file::
@aiohttp.streamer
async def file_sender(writer, file_name=None):
with open(file_name, 'rb') as f:
chunk = f.read(2**16)
while chunk:
await writer.write(chunk)
chunk = f.read(2**16)
Then you can use `file_sender` like this:
async with session.post('http://httpbin.org/post',
data=file_sender(file_name='huge_file')) as resp:
print(await resp.text())
..note:: Coroutine must accept `writer` as first argument
N )Payloadpayload_typestreamerc @ s( e Z d Z d d Z d d Z d S)_stream_wrapperc C s( t j | | _ | | _ | | _ d S)N)asyncio coroutinecoroargskwargs)selfr r
r r
/payload_streamer.py__init__"