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
81 lines
2.8 KiB
PHP
81 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace DeliciousBrains\WP_Offload_Media\Aws3\Aws\S3\Exception;
|
|
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\CommandInterface;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Exception\AwsException;
|
|
use DeliciousBrains\WP_Offload_Media\Aws3\Aws\Multipart\UploadState;
|
|
class S3MultipartUploadException extends \DeliciousBrains\WP_Offload_Media\Aws3\Aws\Exception\MultipartUploadException
|
|
{
|
|
/** @var string Bucket of the transfer object */
|
|
private $bucket;
|
|
/** @var string Key of the transfer object */
|
|
private $key;
|
|
/** @var string Source file name of the transfer object */
|
|
private $filename;
|
|
/**
|
|
* @param UploadState $state Upload state at time of the exception.
|
|
* @param \Exception|array $prev Exception being thrown. Could be an array of
|
|
* AwsExceptions being thrown when uploading parts
|
|
* for one object, or an instance of AwsException
|
|
* for a specific Multipart error being thrown in
|
|
* the MultipartUpload process.
|
|
*/
|
|
public function __construct(UploadState $state, $prev = null)
|
|
{
|
|
if (\is_array($prev) && ($error = $prev[\key($prev)])) {
|
|
$this->collectPathInfo($error->getCommand());
|
|
} elseif ($prev instanceof AwsException) {
|
|
$this->collectPathInfo($prev->getCommand());
|
|
}
|
|
parent::__construct($state, $prev);
|
|
}
|
|
/**
|
|
* Get the Bucket information of the transfer object
|
|
*
|
|
* @return string|null Returns null when 'Bucket' information
|
|
* is unavailable.
|
|
*/
|
|
public function getBucket()
|
|
{
|
|
return $this->bucket;
|
|
}
|
|
/**
|
|
* Get the Key information of the transfer object
|
|
*
|
|
* @return string|null Returns null when 'Key' information
|
|
* is unavailable.
|
|
*/
|
|
public function getKey()
|
|
{
|
|
return $this->key;
|
|
}
|
|
/**
|
|
* Get the source file name of the transfer object
|
|
*
|
|
* @return string|null Returns null when metadata of the stream
|
|
* wrapped in 'Body' parameter is unavailable.
|
|
*/
|
|
public function getSourceFileName()
|
|
{
|
|
return $this->filename;
|
|
}
|
|
/**
|
|
* Collect file path information when accessible. (Bucket, Key)
|
|
*
|
|
* @param CommandInterface $cmd
|
|
*/
|
|
private function collectPathInfo(CommandInterface $cmd)
|
|
{
|
|
if (empty($this->bucket) && isset($cmd['Bucket'])) {
|
|
$this->bucket = $cmd['Bucket'];
|
|
}
|
|
if (empty($this->key) && isset($cmd['Key'])) {
|
|
$this->key = $cmd['Key'];
|
|
}
|
|
if (empty($this->filename) && isset($cmd['Body'])) {
|
|
$this->filename = $cmd['Body']->getMetadata('uri');
|
|
}
|
|
}
|
|
}
|