Note that there are some explanatory texts on larger screens.

plurals
  1. POForcing Download from s3 amazon servers
    primarykey
    data
    text
    <p>I've been developing a new web application which relies on <strong>Amazon S3</strong> servers as storage system, and <strong>Codeiginter</strong> as the PHP framework. </p> <p>I need to force the file to download when the link is clicked. The original URL looks like this:</p> <p><code>http://www.our-web.com/download/do/1.jpg</code></p> <p>which generates a temporary signed URL to the actual file on the Amazon S3 servers like this:</p> <p><code>http://main_bucket.s3.amazonaws.com/post/1/1.jpg?AWSAccessKeyId=AKIAJEOQKYPKC3CCU5RA&amp;Expires=1305395426&amp;Signature=iuzCdA22gImLK192%2BMAhk8OkAY8%3D</code></p> <p>I need to make the file start downloading from the real Amazon URL it soon as the user clicks the link.</p> <p>I have two ways now to do so: </p> <ol> <li>Use <code>redirect()</code> which will open the file not download it; or</li> <li><p>Alter headers as this code:</p> <pre><code>header('Content-type: application/force-download'); header('Content-Disposition: attachment; filename=' . $file_name); header('Content-Transfer-Encoding: binary'); header('Expires: 4000'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($generated_file)); readfile($generated_file); </code></pre></li> </ol> <p>Unfortunately, both ways don't help me. The second method causes the download to come from my website and not from directly from Amazon.</p> <p>How can I force the file to download directly from the Amazon S3 servers, and not from my website?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload