I have an app that is using the Amazon S3 for storing files. I ran into a problem where a large PDF was not downloading using chrome. Smaller PDFs work great, but this larger would not work. I don't believe it is an issue with the PDF, I suspect that it has to do with the size of the file.
When viewing the file in the browser here is the code I am using:
header("Content-type: $filetype");
header("Content-Disposition: filename=\"".$filename."\"");
$response = $s3->get_object(AMAZON_BUCKET, $filepath);
echo $response->body;
This works great for smaller files, but today I ran into a problem where this large PDF would not show. I am thinking the file is too big to be rendered. Therefore I decided to try to force files to be downloaded instead of viewed in the browser if they are too big. So here is the code I am trying to get to work, but I must be doing something wrong because it is not working.
$response = $s3->get_object(AMAZON_BUCKET, $filepath, array(
'response' => array(
'content-type' => $filetype,
'content-disposition' => 'attachment'
)
));
How do I use the Amazon SDK for PHP to force a large file to download?