protected function getS3Client($region = false, $errorCollector = null) {
		if(!$this->enabled()) {
			return null;
		}

		if(empty($region)) {
			if(empty($this->region)) {
				$this->region = $this->getBucketRegion();
				if(empty($this->region)) {
                    if ($errorCollector) {
                        $errorCollector->addError('Could not determine region.');
                    }

					Logger::info("Could not get region from server.");

					return null;
				}

				update_option('ilab-media-s3-region', $this->region);
			}

			$region = $this->region;
		}

		if(empty($region)) {
            if ($errorCollector) {
                $errorCollector->addError("Could not determine region or the region was not specified.");
            }

			return null;
		}

		$config = [
			'version' => 'latest',
			'credentials' => [
				'key' => $this->key,
				'secret' => $this->secret
			],
			'region' => $region
		];

		if(!empty($this->endpoint)) {
			$config['endpoint'] = $this->endpoint;
			if($this->endPointPathStyle) {
				$config['use_path_style_endpoint'] = true;
			}
		}

		if($this->useTransferAcceleration) {
			$config['use_accelerate_endpoint'] = true;
		}

		$s3 = new S3Client($config);

		return $s3;
	}