How can I come up with a functionality in vue.js that access files from a laravel 5.4 storage/app. I just need a functionality in vue.js that I can implement through a link.
I need to implement a file upload and download functionality in my laravel 5.4 and vue.js application. So far the file uploads are running smoothly but the problem is the file downloading. I am getting a notFoundHttpException when I try to click on the link instead of getting the downloads. I have created the following method in my DocumentController:
public function returnDocument($id)
{
$document = Document::findOrFail($id);
\Log::info($document);
// abort unless Auth owns the doc ID
// abort_unless(($document->user_id == Auth::user()->id || Auth::user()->role != 'tenant'), 403);
if ($document->type == "contract") {
return response()->download(storage_path('contracts/' . $document->location));
}
// serve the doc back as a download
$storagePath = Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
return response()->download($storagePath . "documents/" . $document->location);
}
///**