I have a pdf file inside the documents folder of my user, which I need to return through a route. For this I wrote the following simple function
public function showPdf(){ return response()->file('/home/victor/Documents/1-39-1.pdf'); }
But when I call this function through a GET, the browser returns the following exception
Method LaravelLumenHttpResponseFactory::file does not exist.
How can I tell lumen that my file is on that path?
Advertisement
Answer
In lumen 7.x this method is named download and can be seen here. This is fairly similar to Laravels file()
, therefor this change should work.
return response()->download('/home/victor/Documents/1-39-1.pdf');