itdeeps
itdeeps

Reputation: 277

force download file from s3 using php

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

Answers (1)

user553180
user553180

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

Related Questions