title: Return multiple files from fastapi
body: <p>Using <a href="https://github.com/tiangolo/fastapi" rel="noreferrer">fastapi</a>, I can't figure out how to send multiple files as a response. For example, to send a single file, I'll use something like this</p>
  
  <pre><code>from fastapi import FastAPI, Response
  
  app = FastAPI()
  
  @app.get("/image_from_id/")
  async def image_from_id(image_id: int):
  
      # Get image from the database
      img = ...
      return Response(content=img, media_type="application/png")
  </code></pre>
  
  <p>However, I'm not sure what it looks like to send a list of images. Ideally, I'd like to do something like this:</p>
  
  <pre><code>@app.get("/images_from_ids/")
  async def image_from_id(image_ids: List[int]):
  
      # Get a list of images from the database
      images = ...
      return Response(content=images, media_type="multipart/form-data")
  </code></pre>
  
  <p>However, this returns the error</p>
  
  <pre><code>    def render(self, content: typing.Any) -&gt; bytes:
          if content is None:
              return b""
          if isinstance(content, bytes):
              return content
  &gt;       return content.encode(self.charset)
  E       AttributeError: 'list' object has no attribute 'encode'
  </code></pre>