From c1b4ed514f0728f306cab26d97fbcfb9e7cb0ad1 Mon Sep 17 00:00:00 2001 From: Konrad Sroga Date: Thu, 5 Mar 2026 16:26:35 +0100 Subject: [PATCH] Pterodactyl files interface update --- .../Pterodactyl/Client/PterodactylFiles.php | 34 +++++++++++++++++++ .../Client/PterodactylFilesInterface.php | 4 +++ 2 files changed, 38 insertions(+) diff --git a/src/Core/Adapter/Pterodactyl/Client/PterodactylFiles.php b/src/Core/Adapter/Pterodactyl/Client/PterodactylFiles.php index 199b0c0b..b03cad0d 100644 --- a/src/Core/Adapter/Pterodactyl/Client/PterodactylFiles.php +++ b/src/Core/Adapter/Pterodactyl/Client/PterodactylFiles.php @@ -223,4 +223,38 @@ public function changePermissions(string $serverId, string $root, array $files): $this->throwClientApiException($response, $response->getStatusCode()); } } + + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws PterodactylClientApiException + */ + public function getDownloadUrl(string $serverId, string $filePath): string + { + $response = $this->makeRequest('GET', "servers/$serverId/files/download", [ + 'query' => ['file' => $filePath], + ]); + $data = $this->validateClientResponse($response, 200); + + return $data['attributes']['url']; + } + + /** + * @throws TransportExceptionInterface + * @throws ServerExceptionInterface + * @throws RedirectionExceptionInterface + * @throws DecodingExceptionInterface + * @throws ClientExceptionInterface + * @throws PterodactylClientApiException + */ + public function getUploadUrl(string $serverId): string + { + $response = $this->makeRequest('GET', "servers/$serverId/files/upload"); + $data = $this->validateClientResponse($response, 200); + + return $data['attributes']['url']; + } } diff --git a/src/Core/Contract/Pterodactyl/Client/PterodactylFilesInterface.php b/src/Core/Contract/Pterodactyl/Client/PterodactylFilesInterface.php index 7a09ed55..401decf3 100644 --- a/src/Core/Contract/Pterodactyl/Client/PterodactylFilesInterface.php +++ b/src/Core/Contract/Pterodactyl/Client/PterodactylFilesInterface.php @@ -31,4 +31,8 @@ public function compressFiles(string $serverId, string $root, array $files): voi public function decompressFile(string $serverId, string $root, string $file): void; public function changePermissions(string $serverId, string $root, array $files): void; + + public function getDownloadUrl(string $serverId, string $filePath): string; + + public function getUploadUrl(string $serverId): string; }