2017-01-12 70 views
0

我試圖打開使用像這樣一個文件響應的S3存儲瀏覽器中的PDF文檔內聯...Laravel 5.3文件響應錯誤

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/http-foundation/File/File.php:37

存在,但如果我剛落,我可以訪問該文檔它成爲一個瀏覽器。文件方法是否不接受url?

回答

0

請嘗試下面的代碼,不確定但可能適用於您。

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.... 
}