Laravel 5 Laravel 5.3文件响应错误

Laravel 5 Laravel 5.3文件响应错误,laravel-5,Laravel 5,我正在尝试使用一个文件响应在浏览器中从S3 bucket内联打开PDF文档,如下所示 public function showReport(Document $document) { return response()->file("https://s3-us-west-2.amazonaws.com/" . $document->path . '/' . $document->file_name . '.' . $document->ext); } 但我得到了这个错误 不存在于 /va

我正在尝试使用一个文件响应在浏览器中从S3 bucket内联打开PDF文档,如下所示

public function showReport(Document $document)
{
    return response()->file("https://s3-us-west-2.amazonaws.com/" . $document->path . '/' . $document->file_name . '.' . $document->ext);
}
但我得到了这个错误

不存在于 /var/www/ssiweb/vendor/symfony/httpfoundation/File/File.php:37


但是如果我把文档放到浏览器中,我就可以访问它。file方法不接受url吗?

尝试下面的代码,不确定,但这可能对您有用

public function showReport(Document $document)
{
  $file_path = "https://s3-us-west-2.amazonaws.com/" . $document->path . '/' . $document->file_name . '.' . $document->ext;
    if (File::isFile($file_path))
    {
        $file = File::get($file_path);
        $response = Response::make($file, 200);
        $response->header('Content-Type', 'application/pdf');

        return $response;
    }
    //Not a file....
}