mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-21 01:12:14 +00:00
controller refactoring part 24
This commit is contained in:
28
src/Domain/Files/Actions/DownloadThumbnailAction.php
Normal file
28
src/Domain/Files/Actions/DownloadThumbnailAction.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace Domain\Files\Actions;
|
||||
|
||||
use Domain\Files\Models\File;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class DownloadThumbnailAction
|
||||
{
|
||||
/**
|
||||
* Get image thumbnail for browser
|
||||
*/
|
||||
public function __invoke(
|
||||
File $file,
|
||||
string $user_id
|
||||
): StreamedResponse {
|
||||
// Get file path
|
||||
$path = "/files/$user_id/{$file->getRawOriginal('thumbnail')}";
|
||||
|
||||
// Check if file exist
|
||||
if (! Storage::exists($path)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
// Return image thumbnail
|
||||
return Storage::download($path, $file->getRawOriginal('thumbnail'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user