需要使用Guzzle 6从Rest API下载文件,但不想将文件保存在本地而是从Web浏览器下载。目前的代码如下,但我认为漏掉了某些东西?
<?php
//code for Guzzle etc removed
$responsesfile = $client->request('GET', 'documents/1234/content',
[
'headers' => [
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/pdf',
'Content-Type' => 'Content-Disposition: attachment; filename="test"'
]
]
);
return $responsesfile;
?>