protected function ensureBucketExists()
{
if ($this->bucketExists) {
return true;
}
if ($this->bucketExists = $this->service->doesBucketExist($this->bucket)) {
return true;
}
if (!$this->options['create']) {
throw new \RuntimeException(sprintf('The configured bucket "%s" does not exist.', $this->bucket));
}
$options = array('Bucket' => $this->bucket);
if ($this->service->getRegion() != 'us-east-1') {
$options['LocationConstraint'] = $this->service->getRegion();
}
$this->service->createBucket($options);
$this->bucketExists = true;
return true;
}