Gaufrette\Adapter\AwsS3::ensureBucketExists PHP Method

ensureBucketExists() protected method

Ensures the specified bucket exists. If the bucket does not exists and the create option is set to true, it will try to create the bucket. The bucket is created using the same region as the supplied client object.
protected ensureBucketExists ( )
    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;
    }