PluginProbe
Media Cloud Sync / 1.3.11
Media Cloud Sync v1.3.11
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / S3 / Exception / S3MultipartUploadException.php

S3MultipartUploadException.php in Media Cloud Sync 1.3.11, at includes/sdk/s3/Aws/S3/Exception/S3MultipartUploadException.php

81 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\S3\Exception;
4
5 use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
6 use Dudlewebs\WPMCS\s3\Aws\Exception\AwsException;
7 use Dudlewebs\WPMCS\s3\Aws\Multipart\UploadState;
8 class S3MultipartUploadException extends \Dudlewebs\WPMCS\s3\Aws\Exception\MultipartUploadException
9 {
10 /** @var string Bucket of the transfer object */
11 private $bucket;
12 /** @var string Key of the transfer object */
13 private $key;
14 /** @var string Source file name of the transfer object */
15 private $filename;
16 /**
17 * @param UploadState $state Upload state at time of the exception.
18 * @param \Exception|array $prev Exception being thrown. Could be an array of
19 * AwsExceptions being thrown when uploading parts
20 * for one object, or an instance of AwsException
21 * for a specific Multipart error being thrown in
22 * the MultipartUpload process.
23 */
24 public function __construct(UploadState $state, $prev = null)
25 {
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 * Get the Bucket information of the transfer object
35 *
36 * @return string|null Returns null when 'Bucket' information
37 * is unavailable.
38 */
39 public function getBucket()
40 {
41 return $this->bucket;
42 }
43 /**
44 * Get the Key information of the transfer object
45 *
46 * @return string|null Returns null when 'Key' information
47 * is unavailable.
48 */
49 public function getKey()
50 {
51 return $this->key;
52 }
53 /**
54 * Get the source file name of the transfer object
55 *
56 * @return string|null Returns null when metadata of the stream
57 * wrapped in 'Body' parameter is unavailable.
58 */
59 public function getSourceFileName()
60 {
61 return $this->filename;
62 }
63 /**
64 * Collect file path information when accessible. (Bucket, Key)
65 *
66 * @param CommandInterface $cmd
67 */
68 private function collectPathInfo(CommandInterface $cmd)
69 {
70 if (empty($this->bucket) && isset($cmd['Bucket'])) {
71 $this->bucket = $cmd['Bucket'];
72 }
73 if (empty($this->key) && isset($cmd['Key'])) {
74 $this->key = $cmd['Key'];
75 }
76 if (empty($this->filename) && isset($cmd['Body'])) {
77 $this->filename = $cmd['Body']->getMetadata('uri');
78 }
79 }
80 }
81