2017-01-12 2 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.... 
}