title: Download private objects amazon s3 api
body: <p>I'm using amazon S3 php to upload and download files.</p>
  
  <p>for exemple to get a private file from amazon s3 I'm using:</p>
  
  <pre><code>// Cast the body to a primitive string
  $bodyAsString = (string) $object['Body'];
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public function getResponse($content, $filename, $length, $contentType)
  {
      $response = new Response();
  
      $response-&gt;headers-&gt;set('Content-Description','File Transfer');
      $response-&gt;headers-&gt;set('Content-Type',$contentType);
      $response-&gt;headers-&gt;set('Content-Disposition','attachment; filename='.basename($filename));
      $response-&gt;headers-&gt;set('Content-Transfer-Encoding','binary');
      $response-&gt;headers-&gt;set('Expires','0');
      $response-&gt;headers-&gt;set('Cache-Control','must-revalidate');
      $response-&gt;headers-&gt;set('Pragma','public');
      $response-&gt;headers-&gt;set('Content-Length',$length);
  
      $response-&gt;setContent($content);
  
      return $response;
  }
  </code></pre>
  
  <p>TO download it</p>
  
  <p>but this is very heavy for the server, is there a solution to directly download private objects from amazon s3 using a link, a little like for public objects with a security.</p>