I\'m trying to make it so that my script will show test.jpg in an Amazon S3 bucket through php. Here\'s what I have so far:
require_once(\'library/AWS/sdk.cl
If you're still looking for a relevant answer in 2019+, With AWS SDK for PHP 3.x and specifically '2006-03-01' with composer, the following worked for me
...
/**
* Download a file
*
* @param string $object_key
* @param string $file_name
* @return void
*/
function download($object_key, $file_name = '') {
if ( empty($file_name) ) {
$file_name = basename($file_path);
}
$cmd = $s3->getCommand('GetObject', [
'Bucket' => '',
'Key' => $object_key,
'ResponseContentDisposition' => "attachment; filename=\"{$file_name}\"",
]);
$signed_url = $s3->createPresignedRequest($cmd, '+15 minutes') // \GuzzleHttp\Psr7\Request
->getUri() // \GuzzleHttp\Psr7\Uri
->__toString();
header("Location: {$signed_url}");
}
download('
NOTE: This is a solution for those who would want to avoid the issues that may arise from proxying the download through their servers by using a direct download link from AWS.