问题描述
我尝试将一个streamedResponse保存到本地文件中,我的流被RabbitMQ调用。
use Symfony\Component\HttpFoundation\StreamedResponse;
public function createFile(): StreamedResponse
{
$response = new StreamedResponse(function(){
// Open output stream
$handle = fopen('PHP://output','w+');
// Add CSV headers
fputcsv($handle,[
'id','name','email'
]);
// Close the output stream
fclose($handle);
},200,[
'Content-Type' => 'text/csv','Content-disposition' => 'attachment; filename="ExportUsers_21_08_2020_12_02_31.csv"',]);
return $response;
}
$response = $this->createFile();
file_put_contents('/path/to/myfile',$response);
任何想法我该怎么做? 预先感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)