title: Download file from cloud disk (S3) with Laravel 5.1
body: <p>I'm having some problems generating a file download response in Laravel 5.1 while trying to download a file from Amazon S3.</p>
  
  <p>This is my controller action:</p>
  
  <pre><code>/**
   * @param GetRequest $request
   * @return \Symfony\Component\HttpFoundation\Response
   */
  public function get(GetRequest $request)
  {
      $fileEntry = $this-&gt;fileRepository-&gt;find();
      $file = Storage::disk('s3')-&gt;get('projects/'.$fileEntry-&gt;project.'/'.$fileEntry-&gt;name);
  
      return $this-&gt;respondDownload($file, $fileEntry-&gt;name, $fileEntry-&gt;type);
  }
  </code></pre>
  
  <p>And this is the <code>respondDownload</code> method:</p>
  
  <pre><code>/**
   * Respond with a file download.
   *
   * @param $fileContent
   * @param $fileName
   * @param $mime
   * @return \Symfony\Component\HttpFoundation\Response
   */
  public function respondDownload($fileContent, $fileName, $mime)
  {
      return (new Response($fileContent, 200))
          -&gt;header('Content-Type', $mime)
          -&gt;header('Content-Disposition', 'attachment; filename="'.$fileName.'"');
  }
  </code></pre>
  
  <p>If I open the developer tools I can see that the response is successful and the content is set to the file content, but the browser is not prompting to save the file somewhere.</p>
  
  <p>How can I solve this problem? Is something wrong with the headers?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I also tried making a streamed response but the browser is still not showing a save file modal.</p>
  
  <pre><code>public function respondDownload($fileContent, $fileName, $mime)
  {
      return (new StreamedResponse(function() use ($fileContent)
      {
          echo $fileContent;
      }, 200, [
          'Content-Type' =&gt; $mime,
          'Content-Disposition' =&gt; 'attachment; filename="'.$fileName.'"'
      ]));
  }
  </code></pre>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Response headers:
  <a href="https://i.stack.imgur.com/RJVKs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RJVKs.png" alt="Response headers"></a></p>
  
  <p>Response content:
  <a href="https://i.stack.imgur.com/Kl768.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kl768.png" alt="Response content"></a></p>