public function createBucket() {
		$bucket_exists = false;

		try {
			$result = $this->client->listBuckets();
		} catch ( \Exception $e ) {
			Log::instance()->write( 'Error Message: ' . $e->getMessage(), 1, 'error' );
			Log::instance()->write( 'AWS Request ID: ' . $e->getAwsRequestId(), 1, 'error' );
			Log::instance()->write( 'AWS Error Type: ' . $e->getAwsErrorType(), 1, 'error' );
			Log::instance()->write( 'AWS Error Code: ' . $e->getAwsErrorCode(), 1, 'error' );

			return $e->getAwsErrorCode();
		}

		$bucket_name = self::getBucketName( $this->repository );

		foreach ( $result['Buckets'] as $bucket ) {
			if ( $bucket_name === $bucket['Name'] ) {
				$bucket_exists = true;
			}
		}

		if ( $bucket_exists ) {
			return 'BucketExists';
		}

		try {
			$result = $this->client->createBucket(
				[
					'Bucket'             => self::getBucketName( $this->repository ),
					'LocationConstraint' => $this->region,
				]
			);
		} catch ( \Exception $e ) {
			Log::instance()->write( 'Error Message: ' . $e->getMessage(), 1, 'error' );
			Log::instance()->write( 'AWS Request ID: ' . $e->getAwsRequestId(), 1, 'error' );
			Log::instance()->write( 'AWS Error Type: ' . $e->getAwsErrorType(), 1, 'error' );
			Log::instance()->write( 'AWS Error Code: ' . $e->getAwsErrorCode(), 1, 'error' );

			return $e->getAwsErrorCode();
		}

		return true;
	}
public function createBucket() {
		$bucket_exists = false;

		try {
			$result = $this->client->listBuckets();
		} catch ( \Exception $e ) {
			Log::instance()->write( 'Error Message: ' . $e->getMessage(), 1, 'error' );
			Log::instance()->write( 'AWS Request ID: ' . $e->getAwsRequestId(), 1, 'error' );
			Log::instance()->write( 'AWS Error Type: ' . $e->getAwsErrorType(), 1, 'error' );
			Log::instance()->write( 'AWS Error Code: ' . $e->getAwsErrorCode(), 1, 'error' );

			return $e->getAwsErrorCode();
		}

		$bucket_name = self::getBucketName( $this->repository );

		foreach ( $result['Buckets'] as $bucket ) {
			if ( $bucket_name === $bucket['Name'] ) {
				$bucket_exists = true;
			}
		}

		if ( $bucket_exists ) {
			return 'BucketExists';
		}

		try {
			$result = $this->client->createBucket(
				[
					'Bucket'             => self::getBucketName( $this->repository ),
					'LocationConstraint' => $this->region,
				]
			);
		} catch ( \Exception $e ) {
			Log::instance()->write( 'Error Message: ' . $e->getMessage(), 1, 'error' );
			Log::instance()->write( 'AWS Request ID: ' . $e->getAwsRequestId(), 1, 'error' );
			Log::instance()->write( 'AWS Error Type: ' . $e->getAwsErrorType(), 1, 'error' );
			Log::instance()->write( 'AWS Error Code: ' . $e->getAwsErrorCode(), 1, 'error' );

			return $e->getAwsErrorCode();
		}

		return true;
	}
public function createBucket ( ) { $ bucket_exists = false ; try { $ result = $ this -> client -> listBuckets ( ) ; } catch ( \ Exception $ e ) { Log :: instance ( ) -> write ( 'Error Message: ' . $ e -> getMessage ( ) , 1 , 'error' ) ; Log :: instance ( ) -> write ( 'AWS Request ID: ' . $ e -> getAwsRequestId ( ) , 1 , 'error' ) ; Log :: instance ( ) -> write ( 'AWS Error Type: ' . $ e -> getAwsErrorType ( ) , 1 , 'error' ) ; Log :: instance ( ) -> write ( 'AWS Error Code: ' . $ e -> getAwsErrorCode ( ) , 1 , 'error' ) ; return $ e -> getAwsErrorCode ( ) ; } $ bucket_name = self :: getBucketName ( $ this -> repository ) ; foreach ( $ result [ 'Buckets' ] as $ bucket ) { if ( $ bucket_name === $ bucket [ 'Name' ] ) { $ bucket_exists = true ; } } if ( $ bucket_exists ) { return 'BucketExists' ; } try { $ result = $ this -> client -> createBucket ( [ 'Bucket' => self :: getBucketName ( $ this -> repository ) , 'LocationConstraint' => $ this -> region , ] ) ; } catch ( \ Exception $ e ) { Log :: instance ( ) -> write ( 'Error Message: ' . $ e -> getMessage ( ) , 1 , 'error' ) ; Log :: instance ( ) -> write ( 'AWS Request ID: ' . $ e -> getAwsRequestId ( ) , 1 , 'error' ) ; Log :: instance ( ) -> write ( 'AWS Error Type: ' . $ e -> getAwsErrorType ( ) , 1 , 'error' ) ; Log :: instance ( ) -> write ( 'AWS Error Code: ' . $ e -> getAwsErrorCode ( ) , 1 , 'error' ) ; return $ e -> getAwsErrorCode ( ) ; } return true ; }
Create WP Snapshots S3 bucket

@return bool|string
Create WP Snapshots S3 bucket