I’m trying to programatically download a zip file from a secured bucket on S3, and once the download is sent to the browser I want a receipt page to be shown.
But I keep getting all kinds of crazy characters that are being output to the browser instead:
$url = "https://s3.amazonaws.com/{$bucket}/{$resource}?{$authentication_params}";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('response-content-type: application/zip', 'response-content-disposition: attachment', 'Expect: 100-continue'));
$response = curl_exec($ch);
curl_close($ch);
If I type $url in the address bar in firefox, the download works. How do I download the file and then continue to my receipt page?
I ended up simply reversing the order of my process and using a meta refresh header for this.