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
This commit is contained in:
71
vendor/Aws3/Aws/Api/Parser/MetadataParserTrait.php
vendored
Normal file
71
vendor/Aws3/Aws/Api/Parser/MetadataParserTrait.php
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace DeliciousBrains\WP_Offload_Media\Aws3\Aws\Api\Parser;
|
||||
|
||||
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Api\DateTimeResult;
|
||||
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Api\Shape;
|
||||
use DeliciousBrains\WP_Offload_Media\Aws3\Psr\Http\Message\ResponseInterface;
|
||||
trait MetadataParserTrait
|
||||
{
|
||||
/**
|
||||
* Extract a single header from the response into the result.
|
||||
*/
|
||||
protected function extractHeader($name, Shape $shape, ResponseInterface $response, &$result)
|
||||
{
|
||||
$value = $response->getHeaderLine($shape['locationName'] ?: $name);
|
||||
switch ($shape->getType()) {
|
||||
case 'float':
|
||||
case 'double':
|
||||
$value = (float) $value;
|
||||
break;
|
||||
case 'long':
|
||||
$value = (int) $value;
|
||||
break;
|
||||
case 'boolean':
|
||||
$value = \filter_var($value, \FILTER_VALIDATE_BOOLEAN);
|
||||
break;
|
||||
case 'blob':
|
||||
$value = \base64_decode($value);
|
||||
break;
|
||||
case 'timestamp':
|
||||
try {
|
||||
$value = DateTimeResult::fromTimestamp($value, !empty($shape['timestampFormat']) ? $shape['timestampFormat'] : null);
|
||||
break;
|
||||
} catch (\Exception $e) {
|
||||
// If the value cannot be parsed, then do not add it to the
|
||||
// output structure.
|
||||
return;
|
||||
}
|
||||
case 'string':
|
||||
if ($shape['jsonvalue']) {
|
||||
$value = $this->parseJson(\base64_decode($value), $response);
|
||||
}
|
||||
break;
|
||||
}
|
||||
$result[$name] = $value;
|
||||
}
|
||||
/**
|
||||
* Extract a map of headers with an optional prefix from the response.
|
||||
*/
|
||||
protected function extractHeaders($name, Shape $shape, ResponseInterface $response, &$result)
|
||||
{
|
||||
// Check if the headers are prefixed by a location name
|
||||
$result[$name] = [];
|
||||
$prefix = $shape['locationName'];
|
||||
$prefixLen = \strlen($prefix);
|
||||
foreach ($response->getHeaders() as $k => $values) {
|
||||
if (!$prefixLen) {
|
||||
$result[$name][$k] = \implode(', ', $values);
|
||||
} elseif (\stripos($k, $prefix) === 0) {
|
||||
$result[$name][\substr($k, $prefixLen)] = \implode(', ', $values);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Places the status code of the response into the result array.
|
||||
*/
|
||||
protected function extractStatus($name, ResponseInterface $response, array &$result)
|
||||
{
|
||||
$result[$name] = (int) $response->getStatusCode();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user