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
67 lines
2.3 KiB
PHP
67 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn;
|
|
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\S3\AccessPointArn as S3AccessPointArn;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\ObjectLambdaAccessPointArn;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\S3\MultiRegionAccessPointArn;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\S3\OutpostsBucketArn;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\S3\RegionalBucketArn;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Arn\S3\OutpostsAccessPointArn;
|
|
/**
|
|
* This class provides functionality to parse ARN strings and return a
|
|
* corresponding ARN object. ARN-parsing logic may be subject to change in the
|
|
* future, so this should not be relied upon for external customer usage.
|
|
*
|
|
* @internal
|
|
*/
|
|
class ArnParser
|
|
{
|
|
/**
|
|
* @param $string
|
|
* @return bool
|
|
*/
|
|
public static function isArn($string)
|
|
{
|
|
return $string !== null && \strpos($string, 'arn:') === 0;
|
|
}
|
|
/**
|
|
* Parses a string and returns an instance of ArnInterface. Returns a
|
|
* specific type of Arn object if it has a specific class representation
|
|
* or a generic Arn object if not.
|
|
*
|
|
* @param $string
|
|
* @return ArnInterface
|
|
*/
|
|
public static function parse($string)
|
|
{
|
|
$data = Arn::parse($string);
|
|
if ($data['service'] === 's3-object-lambda') {
|
|
return new ObjectLambdaAccessPointArn($string);
|
|
}
|
|
$resource = self::explodeResourceComponent($data['resource']);
|
|
if ($resource[0] === 'outpost') {
|
|
if (isset($resource[2]) && $resource[2] === 'bucket') {
|
|
return new OutpostsBucketArn($string);
|
|
}
|
|
if (isset($resource[2]) && $resource[2] === 'accesspoint') {
|
|
return new OutpostsAccessPointArn($string);
|
|
}
|
|
}
|
|
if (empty($data['region'])) {
|
|
return new MultiRegionAccessPointArn($string);
|
|
}
|
|
if ($resource[0] === 'accesspoint') {
|
|
if ($data['service'] === 's3') {
|
|
return new S3AccessPointArn($string);
|
|
}
|
|
return new AccessPointArn($string);
|
|
}
|
|
return new Arn($data);
|
|
}
|
|
private static function explodeResourceComponent($resource)
|
|
{
|
|
return \preg_split("/[\\/:]/", $resource);
|
|
}
|
|
}
|