| 1 |
<?php |
| 2 |
namespace Aws\S3\Exception; |
| 3 |
|
| 4 |
use Aws\CommandInterface; |
| 5 |
use Aws\Exception\AwsException; |
| 6 |
use Aws\Multipart\UploadState; |
| 7 |
|
| 8 |
class S3MultipartUploadException extends \Aws\Exception\MultipartUploadException |
| 9 |
{ |
| 10 |
|
| 11 |
private $bucket; |
| 12 |
|
| 13 |
private $key; |
| 14 |
|
| 15 |
private $filename; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
public function __construct(UploadState $state, $prev = null) { |
| 26 |
if (is_array($prev) && $error = $prev[key($prev)]) { |
| 27 |
$this->collectPathInfo($error->getCommand()); |
| 28 |
} elseif ($prev instanceof AwsException) { |
| 29 |
$this->collectPathInfo($prev->getCommand()); |
| 30 |
} |
| 31 |
parent::__construct($state, $prev); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
public function getBucket() |
| 41 |
{ |
| 42 |
return $this->bucket; |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public function getKey() |
| 52 |
{ |
| 53 |
return $this->key; |
| 54 |
} |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public function getSourceFileName() |
| 63 |
{ |
| 64 |
return $this->filename; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
private function collectPathInfo(CommandInterface $cmd) |
| 73 |
{ |
| 74 |
if (empty($this->bucket) && isset($cmd['Bucket'])) { |
| 75 |
$this->bucket = $cmd['Bucket']; |
| 76 |
} |
| 77 |
if (empty($this->key) && isset($cmd['Key'])) { |
| 78 |
$this->key = $cmd['Key']; |
| 79 |
} |
| 80 |
if (empty($this->filename) && isset($cmd['Body'])) { |
| 81 |
$this->filename = $cmd['Body']->getMetadata('uri'); |
| 82 |
} |
| 83 |
} |
| 84 |
} |