installed plugin Infinite Uploads
version 2.0.8
This commit is contained in:
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace UglyRobot\Infinite_Uploads\Aws\S3\Exception;
|
||||
|
||||
use UglyRobot\Infinite_Uploads\Aws\HasMonitoringEventsTrait;
|
||||
use UglyRobot\Infinite_Uploads\Aws\MonitoringEventsInterface;
|
||||
/**
|
||||
* Exception thrown when errors occur while deleting objects using a
|
||||
* {@see S3\BatchDelete} object.
|
||||
*/
|
||||
class DeleteMultipleObjectsException extends \Exception implements \UglyRobot\Infinite_Uploads\Aws\MonitoringEventsInterface
|
||||
{
|
||||
use HasMonitoringEventsTrait;
|
||||
private $deleted = [];
|
||||
private $errors = [];
|
||||
/**
|
||||
* @param array $deleted Array of successfully deleted keys
|
||||
* @param array $errors Array of errors that were encountered
|
||||
*/
|
||||
public function __construct(array $deleted, array $errors)
|
||||
{
|
||||
$this->deleted = array_values($deleted);
|
||||
$this->errors = array_values($errors);
|
||||
parent::__construct('Unable to delete certain keys when executing a' . ' DeleteMultipleObjects request: ' . self::createMessageFromErrors($errors));
|
||||
}
|
||||
/**
|
||||
* Create a single error message from multiple errors.
|
||||
*
|
||||
* @param array $errors Errors encountered
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function createMessageFromErrors(array $errors)
|
||||
{
|
||||
return "\n- " . implode("\n- ", array_map(function ($key) {
|
||||
return json_encode($key);
|
||||
}, $errors));
|
||||
}
|
||||
/**
|
||||
* Get the errored objects
|
||||
*
|
||||
* @return array Returns an array of associative arrays, each containing
|
||||
* a 'Code', 'Message', and 'Key' key.
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
return $this->errors;
|
||||
}
|
||||
/**
|
||||
* Get the successfully deleted objects
|
||||
*
|
||||
* @return array Returns an array of associative arrays, each containing
|
||||
* a 'Key' and optionally 'DeleteMarker' and
|
||||
* 'DeleterMarkerVersionId'
|
||||
*/
|
||||
public function getDeleted()
|
||||
{
|
||||
return $this->deleted;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace UglyRobot\Infinite_Uploads\Aws\S3\Exception;
|
||||
|
||||
class PermanentRedirectException extends \UglyRobot\Infinite_Uploads\Aws\S3\Exception\S3Exception
|
||||
{
|
||||
}
|
11
wp-content/plugins/infinite-uploads/vendor/Aws3/Aws/S3/Exception/S3Exception.php
vendored
Normal file
11
wp-content/plugins/infinite-uploads/vendor/Aws3/Aws/S3/Exception/S3Exception.php
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace UglyRobot\Infinite_Uploads\Aws\S3\Exception;
|
||||
|
||||
use UglyRobot\Infinite_Uploads\Aws\Exception\AwsException;
|
||||
/**
|
||||
* Represents an error interacting with the Amazon Simple Storage Service.
|
||||
*/
|
||||
class S3Exception extends \UglyRobot\Infinite_Uploads\Aws\Exception\AwsException
|
||||
{
|
||||
}
|
80
wp-content/plugins/infinite-uploads/vendor/Aws3/Aws/S3/Exception/S3MultipartUploadException.php
vendored
Normal file
80
wp-content/plugins/infinite-uploads/vendor/Aws3/Aws/S3/Exception/S3MultipartUploadException.php
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace UglyRobot\Infinite_Uploads\Aws\S3\Exception;
|
||||
|
||||
use UglyRobot\Infinite_Uploads\Aws\CommandInterface;
|
||||
use UglyRobot\Infinite_Uploads\Aws\Exception\AwsException;
|
||||
use UglyRobot\Infinite_Uploads\Aws\Multipart\UploadState;
|
||||
class S3MultipartUploadException extends \UglyRobot\Infinite_Uploads\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(\UglyRobot\Infinite_Uploads\Aws\Multipart\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(\UglyRobot\Infinite_Uploads\Aws\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');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user