mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-19 00:22:15 +00:00
controller refactoring part 24
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Actions\DownloadFileAction;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
class GetFileController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RecordDownloadAction $recordDownload,
|
||||
){}
|
||||
private DownloadFileAction $downloadFile,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
@@ -23,8 +22,7 @@ class GetFileController extends Controller
|
||||
public function __invoke(
|
||||
Request $request,
|
||||
string $filename,
|
||||
): StreamedResponse {
|
||||
|
||||
): BinaryFileResponse {
|
||||
// Get file record
|
||||
$file = UserFile::withTrashed()
|
||||
->where('user_id', Auth::id())
|
||||
@@ -37,6 +35,6 @@ class GetFileController extends Controller
|
||||
user_id: Auth::id(),
|
||||
);
|
||||
|
||||
return $this->helper->download_file($file, Auth::id());
|
||||
return ($this->downloadFile)($file, Auth::id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,33 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Actions\DownloadThumbnailAction;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
|
||||
class GetThumbnailController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private DownloadThumbnailAction $downloadThumbnail,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get image thumbnail
|
||||
*/
|
||||
public function __invoke(
|
||||
Request $request,
|
||||
string $filename,
|
||||
): FileNotFoundException|StreamedResponse {
|
||||
|
||||
): FileNotFoundException | StreamedResponse {
|
||||
$file = UserFile::withTrashed()
|
||||
->whereUserId(Auth::id())
|
||||
->whereThumbnail($filename)
|
||||
->firstOrFail();
|
||||
|
||||
return $this->helper->download_thumbnail_file($file, Auth::id());
|
||||
return ($this->downloadThumbnail)($file, Auth::id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
|
||||
use Domain\Sharing\Models\Share;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Files\Actions\DownloadFileAction;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
/**
|
||||
* Get file public
|
||||
@@ -16,14 +14,15 @@ use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
class VisitorGetFileController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RecordDownloadAction $recordDownload
|
||||
){}
|
||||
private DownloadFileAction $downloadFile,
|
||||
private RecordDownloadAction $recordDownload,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
$filename,
|
||||
Share $shared,
|
||||
): StreamedResponse {
|
||||
|
||||
): BinaryFileResponse {
|
||||
// Check ability to access protected share files
|
||||
$this->helper->check_protected_share_record($shared);
|
||||
|
||||
@@ -41,6 +40,6 @@ class VisitorGetFileController extends Controller
|
||||
user_id: $shared->user_id,
|
||||
);
|
||||
|
||||
return $this->helper->download_file($file, $shared->user_id);
|
||||
return ($this->downloadFile)($file, $shared->user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
|
||||
use Domain\Sharing\Models\Share;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
use Domain\Files\Actions\DownloadThumbnailAction;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
@@ -17,10 +15,11 @@ class VisitorGetThumbnailController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private RecordDownloadAction $recordDownload,
|
||||
) {}
|
||||
private DownloadThumbnailAction $downloadThumbnail,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(
|
||||
|
||||
$filename,
|
||||
Share $shared,
|
||||
): StreamedResponse {
|
||||
@@ -41,6 +40,6 @@ class VisitorGetThumbnailController extends Controller
|
||||
user_id: $shared->user_id,
|
||||
);
|
||||
|
||||
return $this->helper->download_thumbnail_file($file, $shared->user_id);
|
||||
return ($this->downloadThumbnail)($file, $shared->user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user