daemonBackupRepository = $daemonBackupRepository; $this->responseFactory = $responseFactory; $this->jwtService = $jwtService; } /** * Download the backup for a given server instance. For daemon local files, the file * will be streamed back through the Panel. For AWS S3 files, a signed URL will be generated * which the user is redirected to. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DownloadBackupRequest $request * @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Backup $backup * @return array */ public function __invoke(DownloadBackupRequest $request, Server $server, Backup $backup) { $token = $this->jwtService ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setClaims([ 'backup_uuid' => $backup->uuid, 'server_uuid' => $server->uuid, ]) ->handle($server->node, $request->user()->id . $server->uuid); return [ 'object' => 'signed_url', 'attributes' => [ 'url' => sprintf( '%s/download/backup?token=%s', $server->node->getConnectionAddress(), $token->__toString() ), ], ]; } }