Files
WPS3Media/vendor/Aws3/Aws/Arn/S3/OutpostsBucketArn.php
Malin 3248cbb029 feat: add S3-compatible storage provider (MinIO, Ceph, R2, etc.)
Adds a new 'S3-Compatible Storage' provider that works with any
S3-API-compatible object storage service, including MinIO, Ceph,
Cloudflare R2, Backblaze B2, and others.

Changes:
- New provider class: classes/providers/storage/s3-compatible-provider.php
  - Provider key: s3compatible
  - Reads user-configured endpoint URL from settings
  - Uses path-style URL access (required by most S3-compatible services)
  - Supports credentials via AS3CF_S3COMPAT_ACCESS_KEY_ID /
    AS3CF_S3COMPAT_SECRET_ACCESS_KEY wp-config.php constants
  - Disables AWS-specific features (Block Public Access, Object Ownership)
- New provider SVG icons (s3compatible.svg, -link.svg, -round.svg)
- Registered provider in main plugin class with endpoint setting support
- Updated StorageProviderSubPage to show endpoint URL input for S3-compatible
- Built pro settings bundle with rollup (Svelte 4.2.19)
- Added package.json and updated rollup.config.mjs for pro-only builds
2026-03-03 12:30:18 +01:00

72 lines
2.7 KiB
PHP

<?php
namespace DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\S3;
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\Arn;
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\Exception\InvalidArnException;
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\ResourceTypeAndIdTrait;
/**
* This class represents an S3 Outposts bucket ARN, which is in the
* following format:
*
* @internal
*/
class OutpostsBucketArn extends Arn implements BucketArnInterface, OutpostsArnInterface
{
use ResourceTypeAndIdTrait;
/**
* Parses a string into an associative array of components that represent
* a OutpostsBucketArn
*
* @param $string
* @return array
*/
public static function parse($string)
{
$data = parent::parse($string);
$data = self::parseResourceTypeAndId($data);
return self::parseOutpostData($data);
}
public function getBucketName()
{
return $this->data['bucket_name'];
}
public function getOutpostId()
{
return $this->data['outpost_id'];
}
private static function parseOutpostData(array $data)
{
$resourceData = \preg_split("/[\\/:]/", $data['resource_id'], 3);
$data['outpost_id'] = isset($resourceData[0]) ? $resourceData[0] : null;
$data['bucket_label'] = isset($resourceData[1]) ? $resourceData[1] : null;
$data['bucket_name'] = isset($resourceData[2]) ? $resourceData[2] : null;
return $data;
}
/**
*
* @param array $data
*/
public static function validate(array $data)
{
Arn::validate($data);
if ($data['service'] !== 's3-outposts') {
throw new InvalidArnException("The 3rd component of an S3 Outposts" . " bucket ARN represents the service and must be 's3-outposts'.");
}
self::validateRegion($data, 'S3 Outposts bucket ARN');
self::validateAccountId($data, 'S3 Outposts bucket ARN');
if ($data['resource_type'] !== 'outpost') {
throw new InvalidArnException("The 6th component of an S3 Outposts" . " bucket ARN represents the resource type and must be" . " 'outpost'.");
}
if (!self::isValidHostLabel($data['outpost_id'])) {
throw new InvalidArnException("The 7th component of an S3 Outposts" . " bucket ARN is required, represents the outpost ID, and" . " must be a valid host label.");
}
if ($data['bucket_label'] !== 'bucket') {
throw new InvalidArnException("The 8th component of an S3 Outposts" . " bucket ARN must be 'bucket'");
}
if (empty($data['bucket_name'])) {
throw new InvalidArnException("The 9th component of an S3 Outposts" . " bucket ARN represents the bucket name and must not be empty.");
}
}
}