title: aiobotocore-aiohttp - Get S3 file content and stream it in the response
body: <p>I want to get the content of an uploaded file on S3 using botocore and aiohttp service. As the files may have a huge size:</p>
  
  <ul>
  <li>I don't want to store the whole file content in memory,</li>
  <li>I want to be able to handle other requests while downloading files from S3 (aiobotocore, aiohttp),</li>
  <li>I want to be able to apply modifications on the files I download, so I want to treat it line by line and stream the response to the client</li>
  </ul>
  
  <p>For now, I have the following code in my aiohttp handler:</p>
  
  <pre><code>import asyncio                                  
  import aiobotocore                              
  
  from aiohttp import web                         
  
  @asyncio.coroutine                              
  def handle_get_file(loop):                      
  
      session = aiobotocore.get_session(loop=loop)
  
      client = session.create_client(             
          service_name="s3",                      
          region_name="",                         
          aws_secret_access_key="",               
          aws_access_key_id="",                   
          endpoint_url="http://s3:5000"           
      )                                           
  
      response = yield from client.get_object(    
          Bucket="mybucket",                      
          Key="key",                              
      )                                           
  </code></pre>
  
  <p>Each time I read one line from the given file, I want to send the response. Actually, get_object() returns a dict with a Body (ClientResponseContentProxy object) inside. Using the method read(), how can I get a chunk of the expected response and stream it to the client ?</p>
  
  <p>When I do :</p>
  
  <pre><code>for content in response['Body'].read(10):
      print("----")                        
      print(content)          
  </code></pre>
  
  <p>The code inside the loop is never executed.</p>
  
  <p>But when I do :</p>
  
  <pre><code>result = yield from response['Body'].read(10)
  </code></pre>
  
  <p>I get the content of the file in result. I am a little bit confused about how to use read() here.</p>
  
  <p>Thanks</p>