I've been developing a new web application which relies on Amazon S3 servers as storage system, and Codeiginter as the PHP framework.
I need to force the file to download when the link is clicked. The original URL looks like this:
http://www.our-web.com/download/do/1.jpg
which generates a temporary signed URL to the actual file on the Amazon S3 servers like this:
http://main_bucket.s3.amazonaws.com/post/1/1.jpg?AWSAccessKeyId=AKIAJEOQKYPKC3CCU5RA&Expires=1305395426&Signature=iuzCdA22gImLK192%2BMAhk8OkAY8%3D
I need to make the file start downloading from the real Amazon URL it soon as the user clicks the link.
I have two ways now to do so:
redirect()
which will open the file not download it; orAlter headers as this code:
header('Content-type: application/force-download');
заголовок ('Content-Disposition: attachment; filename ='. $ file_name);
заголовок ('Content-Transfer-Encoding: двоичный');
заголовок ('Истекает: 4000');
заголовок ('Cache-Control: must-revalidate, post-check = 0, pre-check = 0');
заголовок ('Pragma: public');
заголовок ('Content-Length:'. Размер файла ($ created_file));
файл чтения ($ created_file);
К сожалению, оба способа мне не помогают. При втором способе загрузка происходит с моего веб-сайта, а не напрямую с Amazon.
Как я могу заставить файл загружаться непосредственно с серверов Amazon S3, а не с моего веб-сайта?