简体   繁体   中英

Amazon S3 SDK: Change filename on download?

Is this the correct way to generate a URL and change it's download name?

$s3 = new AmazonS3();
$opt =  array('response' => array('Content-Disposition' => 'attachment; "filename=newname.txt"'));
$url = $s3->get_object_url('bucket', 'file.txt', '5 minutes', $opt));

Apparently doesn't work with me.

After several tests, apparently get_object_url requires Content-Disposition parameter to be in lower case.

Note that this is not the case for create_object which works case-insensitive.

So the working code for above is:

$opt =  array('response' => array('content-disposition' => 'attachment; "filename=newname.txt"'));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM