1 | <?php |
||
22 | class AmazonS3v3 extends AmazonS3 |
||
23 | { |
||
24 | use Cleanable; |
||
25 | |||
26 | /** |
||
27 | * Amazon S3 client. |
||
28 | * |
||
29 | * @var S3Client; |
||
30 | */ |
||
31 | protected $client; |
||
32 | |||
33 | /** |
||
34 | * Configure the sync. |
||
35 | * |
||
36 | * @see \phpbu\App\Backup\Sync::setup() |
||
37 | * @param array $config |
||
38 | * @throws \phpbu\App\Backup\Sync\Exception |
||
39 | * @throws \phpbu\App\Exception |
||
40 | */ |
||
41 | 11 | public function setup(array $config) |
|
47 | |||
48 | /** |
||
49 | * Execute the sync. |
||
50 | * |
||
51 | * @see \phpbu\App\Backup\Sync::sync() |
||
52 | * @param \phpbu\App\Backup\Target $target |
||
53 | * @param \phpbu\App\Result $result |
||
54 | * @throws \phpbu\App\Backup\Sync\Exception |
||
55 | */ |
||
56 | 2 | public function sync(Target $target, Result $result) |
|
74 | |||
75 | /** |
||
76 | * Create the AWS client. |
||
77 | * |
||
78 | * @return \Aws\S3\S3Client |
||
79 | */ |
||
80 | protected function createClient() : S3Client |
||
91 | |||
92 | /** |
||
93 | * Create a multi part s3 file uploader. |
||
94 | * |
||
95 | * @param \phpbu\App\Backup\Target $target |
||
96 | * @param \Aws\S3\S3Client $s3 |
||
97 | * @return \Aws\S3\MultipartUploader |
||
98 | */ |
||
99 | protected function createUploader(Target $target, S3Client $s3) : MultipartUploader |
||
106 | |||
107 | /** |
||
108 | * Creates collector for Amazon S3 |
||
109 | * |
||
110 | * @param \phpbu\App\Backup\Target $target |
||
111 | * @return \phpbu\App\Backup\Collector |
||
112 | */ |
||
113 | protected function createCollector(Target $target) : Collector |
||
118 | |||
119 | /** |
||
120 | * Simulate the sync execution. |
||
121 | * |
||
122 | * @param \phpbu\App\Backup\Target $target |
||
123 | * @param \phpbu\App\Result $result |
||
124 | */ |
||
125 | 1 | public function simulate(Target $target, Result $result) |
|
131 | |||
132 | /** |
||
133 | * Create a s3 bucket. |
||
134 | * |
||
135 | * @param \Aws\S3\S3Client $s3 |
||
136 | */ |
||
137 | 1 | private function createBucket(S3Client $s3) |
|
147 | |||
148 | /** |
||
149 | * Upload backup to Amazon S3 bucket. |
||
150 | * |
||
151 | * @param \phpbu\App\Backup\Target $target |
||
152 | * @param \Aws\S3\S3Client $s3 |
||
153 | * @throws \phpbu\App\Backup\Sync\Exception |
||
154 | * @throws \phpbu\App\Exception |
||
155 | */ |
||
156 | 2 | private function upload(Target $target, S3Client $s3) |
|
164 | |||
165 | /** |
||
166 | * Upload via stream wrapper. |
||
167 | * |
||
168 | * @param \phpbu\App\Backup\Target $target |
||
169 | * @param \Aws\S3\S3Client $s3 |
||
170 | * @throws \phpbu\App\Backup\Sync\Exception |
||
171 | */ |
||
172 | private function uploadStream(Target $target, S3Client $s3) |
||
182 | |||
183 | /** |
||
184 | * Upload via multi part. |
||
185 | * |
||
186 | * @param \phpbu\App\Backup\Target $target |
||
187 | * @param \Aws\S3\S3Client $s3 |
||
188 | * @param \Aws\Exception\MultipartUploadException |
||
189 | */ |
||
190 | 2 | private function uploadMultiPart(Target $target, S3Client $s3) |
|
195 | |||
196 | /** |
||
197 | * Open stream and validate it. |
||
198 | * |
||
199 | * @param string $path |
||
200 | * @param string $mode |
||
201 | * @return resource |
||
202 | * @throws \phpbu\App\Backup\Sync\Exception |
||
203 | */ |
||
204 | private function getFileHandle($path, $mode) |
||
212 | |||
213 | /** |
||
214 | * Get the s3 upload path |
||
215 | * |
||
216 | * @param \phpbu\App\Backup\Target $target |
||
217 | * @return string |
||
218 | */ |
||
219 | 2 | public function getUploadPath(Target $target) |
|
223 | } |
||
224 |