mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 16:32:15 +00:00
Generate multiple avatar sizes for better performance loading and frugal traffic
This commit is contained in:
@@ -3,8 +3,8 @@ namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
use Gate;
|
||||
use Illuminate\Http\Request;
|
||||
use Domain\Files\Models\File;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Actions\DownloadThumbnailAction;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
@@ -20,14 +20,16 @@ class GetThumbnailController extends Controller
|
||||
string $filename,
|
||||
): FileNotFoundException | StreamedResponse {
|
||||
|
||||
$file = UserFile::withTrashed()
|
||||
->where('thumbnail', $filename)
|
||||
$originalFileName = substr($filename, 3);
|
||||
|
||||
$file = File::withTrashed()
|
||||
->where('basename', $originalFileName)
|
||||
->firstOrFail();
|
||||
|
||||
if (! Gate::any(['can-edit', 'can-view'], [$file, null])) {
|
||||
abort(403, 'Access Denied');
|
||||
}
|
||||
|
||||
return ($this->downloadThumbnail)($file, $file->user_id);
|
||||
return ($this->downloadThumbnail)($filename, $file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,11 @@ class VisitorGetThumbnailController extends Controller
|
||||
// Check ability to access protected share files
|
||||
($this->protectShareRecord)($shared);
|
||||
|
||||
$originalFileName = substr($filename, 3);
|
||||
|
||||
// Get file record
|
||||
$file = UserFile::where('user_id', $shared->user_id)
|
||||
->where('thumbnail', $filename)
|
||||
->where('basename', $originalFileName)
|
||||
->firstOrFail();
|
||||
|
||||
// Check file access
|
||||
@@ -44,7 +46,7 @@ class VisitorGetThumbnailController extends Controller
|
||||
user_id: $shared->user_id,
|
||||
);
|
||||
|
||||
// Finally download thumbnail
|
||||
return ($this->downloadThumbnail)($file, $shared->user_id);
|
||||
// Finally, download thumbnail
|
||||
return ($this->downloadThumbnail)($filename, $file);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user