What's the result of storage_path('foo' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'myfile.csv')? is that the full physical path of the file?
Sep 15, 2022
5
Level 3
How to pass private file to API
I'm trying to download a private file from my API, but I'm only getting part of it (the last line).
Here is what I'm doing:
Route::get('mydata/download', fn (Request $request) => response()->download(storage_path('foo' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'myfile.csv')));
What the correct way to access and return a private file ?
Level 102
@devondahon Start by testing it by just downloading it directly in the browser by visiting the url. If that works as expected, you can show the axios code, as the laravel part works. As far as I know handling downloads with only JS can be quite tricky.
Please or to participate in this conversation.