| @@ 258-282 (lines=25) @@ | ||
| 255 | * @throws \RuntimeException if the bucket does not exists or could not be |
|
| 256 | * created |
|
| 257 | */ |
|
| 258 | protected function ensureBucketExists() |
|
| 259 | { |
|
| 260 | if ($this->bucketExists) { |
|
| 261 | return true; |
|
| 262 | } |
|
| 263 | ||
| 264 | if ($this->bucketExists = $this->service->doesBucketExist($this->bucket)) { |
|
| 265 | return true; |
|
| 266 | } |
|
| 267 | ||
| 268 | if (!$this->options['create']) { |
|
| 269 | throw new \RuntimeException(sprintf( |
|
| 270 | 'The configured bucket "%s" does not exist.', |
|
| 271 | $this->bucket |
|
| 272 | )); |
|
| 273 | } |
|
| 274 | ||
| 275 | $this->service->createBucket([ |
|
| 276 | 'Bucket' => $this->bucket, |
|
| 277 | 'LocationConstraint' => $this->service->getRegion(), |
|
| 278 | ]); |
|
| 279 | $this->bucketExists = true; |
|
| 280 | ||
| 281 | return true; |
|
| 282 | } |
|
| 283 | ||
| 284 | protected function getOptions($key, array $options = []) |
|
| 285 | { |
|
| @@ 263-286 (lines=24) @@ | ||
| 260 | * @throws \RuntimeException if the bucket does not exists or could not be |
|
| 261 | * created |
|
| 262 | */ |
|
| 263 | protected function ensureBucketExists() |
|
| 264 | { |
|
| 265 | if ($this->bucketExists) { |
|
| 266 | return true; |
|
| 267 | } |
|
| 268 | ||
| 269 | if ($this->bucketExists = $this->service->bucketExists(['Bucket' => $this->bucket])->isSuccess()) { |
|
| 270 | return true; |
|
| 271 | } |
|
| 272 | ||
| 273 | if (!$this->options['create']) { |
|
| 274 | throw new \RuntimeException(sprintf( |
|
| 275 | 'The configured bucket "%s" does not exist.', |
|
| 276 | $this->bucket |
|
| 277 | )); |
|
| 278 | } |
|
| 279 | ||
| 280 | $this->service->createBucket([ |
|
| 281 | 'Bucket' => $this->bucket, |
|
| 282 | ]); |
|
| 283 | $this->bucketExists = true; |
|
| 284 | ||
| 285 | return true; |
|
| 286 | } |
|
| 287 | ||
| 288 | protected function getOptions($key, array $options = []) |
|
| 289 | { |
|