mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-18 08:12:15 +00:00
controller refactoring part 23
This commit is contained in:
28
src/App/Users/Controllers/GetAvatarController.php
Normal file
28
src/App/Users/Controllers/GetAvatarController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Users\Controllers;
|
||||
|
||||
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class GetAvatarController
|
||||
{
|
||||
/**
|
||||
* Get user avatar
|
||||
*/
|
||||
public function __invoke(
|
||||
string $basename
|
||||
): StreamedResponse|FileNotFoundException {
|
||||
|
||||
// Check if file exist
|
||||
if (! Storage::exists("/avatars/$basename")) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// Return avatar
|
||||
return Storage::download("/avatars/$basename", $basename);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user