jwtService = $jwtService; } /** * Returns a url where files can be uploaded to. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Files\UploadFileRequest $request * @param \Pterodactyl\Models\Server $server * * @return \Illuminate\Http\JsonResponse */ public function __invoke(UploadFileRequest $request, Server $server) { return new JsonResponse([ 'object' => 'signed_url', 'attributes' => [ 'url' => $this->getUploadUrl($server, $request->user()), ], ]); } /** * Returns a url where files can be uploaded to. * * @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\User $user * @return string */ protected function getUploadUrl(Server $server, User $user) { $token = $this->jwtService ->setExpiresAt(CarbonImmutable::now()->addMinutes(15)) ->setClaims([ 'server_uuid' => $server->uuid, ]) ->handle($server->node, $user->id . $server->uuid); return sprintf( '%s/upload/file?token=%s', $server->node->getConnectionAddress(), $token->toString() ); } }