Laravel 5.5文件下载呼叫到未定义的方法binaryfileresponse :: withCookie()



升级到Laravel 5.5后,此代码:

    $headers = ['Content-Type: ' . $fileData[2]];
    return Response::download($fileData[0], $fileData[1] ,$headers);

生成此错误:

Call to undefined method SymfonyComponentHttpFoundationBinaryFileResponse::withCookie()
in CreateFreshApiToken.php (line 51)
at CreateFreshApiToken->handle(object(Request), object(Closure))
in Pipeline.php (line 149)

有什么想法吗?可能是一个错误吗?它与Laravel 5.4。

效果很好

您应该验证CreateFreshApiToken.php的作用。Response::download返回SymfonyComponentHttpFoundationBinaryFileResponse,此类没有withCookie方法。在Laravel 5.4中,似乎完全一样。如果它无助于包括此类代码以及您在AppHttpKernel.php文件中使用的中间件。

在此pr http://github.com/laravel/lasport/passport/pull/474中,Laravel Passport似乎有些破坏了。您还可以查看http://github.com/laravel/passport/issues/489,如果可能的话,也许可以从Web中间件中删除此路线,并等待在Laravel Passport中进行修复

最新更新