title: Symfony2: How to display/download a BLOB field
body: <p>For my client I have to use blob storage for some various files.</p>
  
  <p>So I have created a independent bundle with a Blob class extends Doctrine\DBAL\Types\Type.
  and with a boot function in the bundle class.</p>
  
  <p>That works pretty fine I can write in the database Blob datas.</p>
  
  <p>But I can't download any document after :/</p>
  
  <p>I have got:</p>
  
  <pre><code>public function downloadAction($id) {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
  
      /* @var $entity Document */
      $entity = $em-&gt;getRepository('Lille3SapBundle:Document')-&gt;find($id);
  
      if (!$entity) {
          throw $this-&gt;createNotFoundException('Unable to find Document entity.');
      }
  
      $file = $entity-&gt;getFichier();
  
      $response = new \Symfony\Component\HttpFoundation\Response($file, 200, array(
          'Content-Type' =&gt; 'application/octet-stream',
          'Content-Length' =&gt; sizeof($file),
          'Content-Disposition' =&gt; 'attachment; filename="'.$entity-&gt;getNomDocument().'"',
      ));
  
      return $response;
  }
  </code></pre>
  
  <p>and I have got an Exception:
  The Response content must be a string or object implementing __toString(), "resource" given. </p>
  
  <p>in fact, the <em>$file</em> values is not the expected BLOB but something like <em>Resource id #123</em></p>
  
  <p>-> I have check blob data fields values, and they are ok in the database</p>
  
  <p>So how can I force in the controller to have the blob row and not a <em>Resource id #111</em></p>