Files
moonwell-web/app/Services/GameClientDownloadService.php
T
2026-03-13 23:33:35 +04:00

37 lines
899 B
PHP

<?php
namespace App\Services;
use Illuminate\Support\Facades\Storage;
use Throwable;
class GameClientDownloadService
{
public function filename(): string
{
return basename($this->objectKey());
}
public function temporaryUrl(): string
{
$disk = Storage::disk(config('moonwell.client.disk'));
$objectKey = $this->objectKey();
$filename = $this->filename();
try {
return $disk->temporaryUrl(
$objectKey,
now()->addMinutes(config('moonwell.client.temporary_url_minutes')),
['ResponseContentDisposition' => sprintf('attachment; filename="%s"', $filename)],
);
} catch (Throwable) {
return $disk->url($objectKey);
}
}
private function objectKey(): string
{
return (string) config('moonwell.client.object_key');
}
}