first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php namespace Common\Files\Controllers;
use Common\Core\BaseController;
use Common\Files\FileEntry;
use Common\Files\Response\DownloadFilesResponse;
use Common\Files\Response\FileResponseFactory;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\StreamedResponse;
class DownloadFileController extends BaseController
{
public function __construct(
protected Request $request,
protected FileEntry $fileEntry,
protected FileResponseFactory $fileResponseFactory,
) {
}
public function download(string $hashes)
{
$hashes = explode(',', $hashes);
$ids = array_map(function ($hash) {
return $this->fileEntry->decodeHash($hash);
}, $hashes);
$ids = array_filter($ids);
if (!$ids) {
abort(404, 'No entry hashes provided.');
}
$entries = $this->fileEntry->whereIn('id', $ids)->get();
$this->authorize('download', [FileEntry::class, $entries]);
return app(DownloadFilesResponse::class)->create($entries);
}
}