mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-25 02:10:39 +00:00
get and browse team folders shared with me
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Gate;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Domain\Files\Models\File as UserFile;
|
||||
use Domain\Files\Actions\DownloadFileAction;
|
||||
use Domain\Traffic\Actions\RecordDownloadAction;
|
||||
@@ -14,28 +13,26 @@ class GetFileController extends Controller
|
||||
public function __construct(
|
||||
private RecordDownloadAction $recordDownload,
|
||||
private DownloadFileAction $downloadFile,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get file
|
||||
*/
|
||||
public function __invoke(
|
||||
Request $request,
|
||||
string $filename,
|
||||
): BinaryFileResponse {
|
||||
// Get file record
|
||||
|
||||
$file = UserFile::withTrashed()
|
||||
->where('user_id', Auth::id())
|
||||
->where('basename', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
if (! Gate::any(['can-edit', 'can-visit'], [$file, null])) {
|
||||
abort(403, 'Access Denied');
|
||||
}
|
||||
|
||||
// Store user download size
|
||||
($this->recordDownload)(
|
||||
file_size: (int) $file->getRawOriginal('filesize'),
|
||||
user_id: Auth::id(),
|
||||
user_id: $file->user_id,
|
||||
);
|
||||
|
||||
return ($this->downloadFile)($file, Auth::id());
|
||||
return ($this->downloadFile)($file, $file->user_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
namespace Domain\Files\Controllers\FileAccess;
|
||||
|
||||
use Gate;
|
||||
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;
|
||||
@@ -13,21 +13,21 @@ class GetThumbnailController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private DownloadThumbnailAction $downloadThumbnail,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get image thumbnail
|
||||
*/
|
||||
public function __invoke(
|
||||
Request $request,
|
||||
string $filename,
|
||||
): FileNotFoundException | StreamedResponse {
|
||||
|
||||
$file = UserFile::withTrashed()
|
||||
->whereUserId(Auth::id())
|
||||
->whereThumbnail($filename)
|
||||
->where('thumbnail', $filename)
|
||||
->firstOrFail();
|
||||
|
||||
return ($this->downloadThumbnail)($file, Auth::id());
|
||||
if (! Gate::any(['can-edit', 'can-visit'], [$file, null])) {
|
||||
abort(403, 'Access Denied');
|
||||
}
|
||||
|
||||
return ($this->downloadThumbnail)($file, $file->user_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user