title: Iterating the streaming_content attribute on django FileResponse
body: <p>I'm working on an api with django rest framework, and I'm writing some unit tests to check critical operations. I'm trying to read the contents of a file after doing a get request</p>
  
  <pre><code>downloaded_file = self.client.get(textfile)
  </code></pre>
  
  <p>The problem is that the object returned is of type: django.http.response.FileResponse which inherits from <a href="https://docs.djangoproject.com/en/1.8/ref/request-response/" rel="noreferrer">StreamingHttpResponse</a>.</p>
  
  <p>I'm trying to iterate over the streaming_content attribute, which supposedly is an iterator, but I cannot iterate, no method <code>next()</code>.</p>
  
  <p>I inspected this object and what i get is map object. Any ideas on how to get the content from this request?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Problem Solved</p>
  
  <p>The returned object is a map, a map takes a function and a iterable:</p>
  
  <p><a href="https://docs.python.org/3.4/library/functions.html#map" rel="noreferrer">https://docs.python.org/3.4/library/functions.html#map</a></p>
  
  <p>What I had to do was to cast the map to a list, access the first element of the list and convert from bytes to string. Not very elegant but it works.</p>
  
  <pre><code>list(response.streaming_content)[0].decode("utf-8")
  </code></pre>