Open SergioWiesner opened 4 years ago
I have the same issue... very annoying
Has there been a solution for this?
The download route calls an endpoint which uses the getDownload()
method on the DownloadController which looks like this:
public function getDownload()
{
$file = $this->lfm->setName(request('file'));
if (!Storage::disk($this->helper->config('disk'))->exists($file->path('storage'))) {
abort(404);
}
return response()->download($file->path('absolute'));
}
response()->download()
is a symphony component which eventually calls the native php function is_file()
to determine if the file exists. This obviously does not check which disk you are using, so anything other than local will fail.
To get around this, I overrode the getDownload()
method on the package controller. Here are my registered routes:
Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['web','auth','access-files','file-permissions']], function () {
\UniSharp\LaravelFilemanager\Lfm::routes();
// override download route
Route::get('/download', [FileManagerController::class, 'download']);
});
And the new controller method:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Storage;
use UniSharp\LaravelFilemanager\Controllers\LfmController;
class FileManagerController extends LfmController
{
public function download() {
$file = $this->lfm->setName(request('file'));
if (!Storage::disk($this->helper->config('disk'))->exists($file->path('storage'))) {
abort(404);
}
return Storage::disk($this->helper->config('disk'))->download($file->path('storage'));
}
}
Thank you so much, it's helped me out <3
Please check the following instructions before submitting a bug :
And provide the followings :