Reputation: 277
I want to download the file directly from s3 to user machine. So I have googled and came up with something like this. But this is not working.
$objInfo = $s3->getObjectInfo('bucket', 'filename.mp3');
$obj = $s3->getObject('bucket', 'filename.mp3');
header('Content-type: ' . $objInfo['type']);
echo $obj->body;
How to force download file not based on URL from s3.
Upvotes: 1
Views: 1493
Reputation: 626
try adding
Content-Disposition: attachment
to the header, optionally you can also specify the filename for the file being downloaded with
Content-Disposition: attachment; filename=somefile.ext
Upvotes: 1