Fix file download link (#959)

* fix mount of DownloadFiles

* fix path in download url
This commit is contained in:
Boy132 2025-01-29 08:32:51 +01:00 committed by GitHub
parent dde5305b3f
commit d5b8a4c501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View File

@ -23,14 +23,21 @@ class DownloadFiles extends Page
#[Locked]
public string $path;
public function mount(string $path, NodeJWTService $service): void
private NodeJWTService $nodeJWTService;
public function boot(NodeJWTService $nodeJWTService): void
{
$this->nodeJWTService = $nodeJWTService;
}
public function mount(string $path): void
{
$this->authorizeAccess();
/** @var Server $server */
$server = Filament::getTenant();
$token = $service
$token = $this->nodeJWTService
->setExpiresAt(CarbonImmutable::now()->addMinutes(15))
->setUser(auth()->user())
->setClaims([

View File

@ -174,7 +174,7 @@ class ListFiles extends ListRecords
->label('Download')
->icon('tabler-download')
->visible(fn (File $file) => $file->is_file)
->url(fn () => DownloadFiles::getUrl(['path' => $this->path]), true),
->url(fn (File $file) => DownloadFiles::getUrl(['path' => join_paths($this->path, $file->name)]), true),
Action::make('move')
->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server))
->label('Move')