AWS S3を使用してファイルにcreatePresignedRequest()を生成しています。ユーザーが新しいウィンドウで開くリンクをクリックすると、強制的にダウンロードしたいと思っています。この機能を有効にするためにできることはありますか?私はドキュメントを見ているが、私は必要なものは見ていない。AWS S3は、preSignedRequestリンクがクリックされたときにファイルを強制ダウンロードします。
$s3 = new S3Client([
'credentials'=>[
'key'=>$key,
'secret'=>$secret,
],
'region'=>'us-west-2',
'version'=>'2006-03-01',
]);
$cmd = $s3->getCommand('GetObject', [
'Bucket' => $buckname,
'Key' => $file,
]);
$request = $s3->createPresignedRequest($cmd, '+7 days');
$secureUrl = (string) $request->getUri();
echo $secureUrl; // When the user clicks on the link - how can I force download the file instead of open in a new window.
関連:http://www.tipsandtricks-hq.com/forum/topic/force-a-file-to-download-instead-of-showing-up-in-the-browser – jarmod