Completed
Push — master ( 1fdcfe...1b14ff )
by
unknown
39:21
created
lib/private/Files/ObjectStore/S3ConnectionTrait.php 2 patches
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,267 +24,267 @@
 block discarded – undo
24 24
 use Psr\Log\LoggerInterface;
25 25
 
26 26
 trait S3ConnectionTrait {
27
-	use S3ConfigTrait;
28
-
29
-	protected string $id;
30
-
31
-	protected bool $test;
32
-
33
-	protected ?S3Client $connection = null;
34
-
35
-	private ?ICache $existingBucketsCache = null;
36
-
37
-	protected function parseParams($params) {
38
-		if (empty($params['bucket'])) {
39
-			throw new \Exception('Bucket has to be configured.');
40
-		}
41
-
42
-		if (isset($params['multibucket']) && $params['multibucket'] === true && isset($params['perBucket'][$params['bucket']])) {
43
-			$params = array_merge($params, $params['perBucket'][$params['bucket']]);
44
-		}
45
-
46
-		$this->id = 'amazon::' . $params['bucket'];
47
-
48
-		$this->test = isset($params['test']);
49
-		$this->bucket = $params['bucket'];
50
-		// Default to 5 like the S3 SDK does
51
-		$this->concurrency = $params['concurrency'] ?? 5;
52
-		$this->proxy = $params['proxy'] ?? false;
53
-		$this->connectTimeout = $params['connect_timeout'] ?? 5;
54
-		$this->timeout = $params['timeout'] ?? 15;
55
-		$this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
56
-		$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
57
-		$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
58
-		$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
59
-		$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
60
-		$this->retriesMaxAttempts = $params['retriesMaxAttempts'] ?? 5;
61
-		$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
62
-		$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
63
-		$params['s3-accelerate'] = $params['hostname'] === 's3-accelerate.amazonaws.com' || $params['hostname'] === 's3-accelerate.dualstack.amazonaws.com';
64
-		if (!isset($params['port']) || $params['port'] === '') {
65
-			$params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
66
-		}
67
-		$params['verify_bucket_exists'] = $params['verify_bucket_exists'] ?? true;
68
-
69
-		if ($params['s3-accelerate']) {
70
-			$params['verify_bucket_exists'] = false;
71
-		}
72
-
73
-		$this->params = $params;
74
-	}
75
-
76
-	public function getBucket() {
77
-		return $this->bucket;
78
-	}
79
-
80
-	public function getProxy() {
81
-		return $this->proxy;
82
-	}
83
-
84
-	/**
85
-	 * Returns the connection
86
-	 *
87
-	 * @return S3Client connected client
88
-	 * @throws \Exception if connection could not be made
89
-	 */
90
-	public function getConnection() {
91
-		if ($this->connection !== null) {
92
-			return $this->connection;
93
-		}
94
-
95
-		if ($this->existingBucketsCache === null) {
96
-			$this->existingBucketsCache = Server::get(ICacheFactory::class)
97
-				->createLocal('s3-bucket-exists-cache');
98
-		}
99
-
100
-		$scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https';
101
-		$base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/';
102
-
103
-		// Adding explicit credential provider to the beginning chain.
104
-		// Including default credential provider (skipping AWS shared config files).
105
-		$provider = CredentialProvider::memoize(
106
-			CredentialProvider::chain(
107
-				$this->paramCredentialProvider(),
108
-				CredentialProvider::defaultProvider(['use_aws_shared_config_files' => false])
109
-			)
110
-		);
111
-
112
-		$options = [
113
-			'version' => $this->params['version'] ?? 'latest',
114
-			'credentials' => $provider,
115
-			'endpoint' => $base_url,
116
-			'region' => $this->params['region'],
117
-			'use_path_style_endpoint' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false,
118
-			'signature_provider' => \Aws\or_chain([self::class, 'legacySignatureProvider'], ClientResolver::_default_signature_provider()),
119
-			'csm' => false,
120
-			'use_arn_region' => false,
121
-			'http' => [
122
-				'verify' => $this->getCertificateBundlePath(),
123
-				'connect_timeout' => $this->connectTimeout,
124
-			],
125
-			'use_aws_shared_config_files' => false,
126
-			'retries' => [
127
-				'mode' => 'standard',
128
-				'max_attempts' => $this->retriesMaxAttempts,
129
-			],
130
-		];
131
-
132
-		if ($this->params['s3-accelerate']) {
133
-			$options['use_accelerate_endpoint'] = true;
134
-		} else {
135
-			$options['endpoint'] = $base_url;
136
-		}
137
-
138
-		if (isset($this->params['request_checksum_calculation'])) {
139
-			$options['request_checksum_calculation'] = $this->params['request_checksum_calculation'];
140
-		}
141
-
142
-		if (isset($this->params['response_checksum_validation'])) {
143
-			$options['response_checksum_validation'] = $this->params['response_checksum_validation'];
144
-		}
145
-
146
-		if ($this->getProxy()) {
147
-			$options['http']['proxy'] = $this->getProxy();
148
-		}
149
-		if (isset($this->params['legacy_auth']) && $this->params['legacy_auth']) {
150
-			$options['signature_version'] = 'v2';
151
-		}
152
-		$this->connection = new S3Client($options);
153
-
154
-		try {
155
-			$logger = Server::get(LoggerInterface::class);
156
-			if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
157
-				$logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.',
158
-					['app' => 'objectstore']);
159
-			}
160
-
161
-			if ($this->params['verify_bucket_exists']) {
162
-				$cacheKey = $this->params['hostname'] . $this->bucket;
163
-				$exist = $this->existingBucketsCache->get($cacheKey) === 1;
164
-
165
-				if (!$exist) {
166
-					if (!$this->connection->doesBucketExist($this->bucket)) {
167
-						try {
168
-							$logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']);
169
-							if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
170
-								throw new StorageNotAvailableException('The bucket will not be created because the name is not dns compatible, please correct it: ' . $this->bucket);
171
-							}
172
-							$this->connection->createBucket(['Bucket' => $this->bucket]);
173
-							Server::get(IEventDispatcher::class)
174
-								->dispatchTyped(new BucketCreatedEvent(
175
-									$this->bucket,
176
-									$options['endpoint'],
177
-									$options['region'],
178
-									$options['version']
179
-								));
180
-							$this->testTimeout();
181
-						} catch (S3Exception $e) {
182
-							$logger->debug('Invalid remote storage.', [
183
-								'exception' => $e,
184
-								'app' => 'objectstore',
185
-							]);
186
-							if ($e->getAwsErrorCode() !== 'BucketAlreadyOwnedByYou') {
187
-								throw new StorageNotAvailableException('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());
188
-							}
189
-						}
190
-					}
191
-					$this->existingBucketsCache->set($cacheKey, 1);
192
-				}
193
-			}
194
-
195
-			// google cloud's s3 compatibility doesn't like the EncodingType parameter
196
-			if (strpos($base_url, 'storage.googleapis.com')) {
197
-				$this->connection->getHandlerList()->remove('s3.auto_encode');
198
-			}
199
-		} catch (S3Exception $e) {
200
-			throw new StorageNotAvailableException('S3 service is unable to handle request: ' . $e->getMessage());
201
-		}
202
-
203
-		return $this->connection;
204
-	}
205
-
206
-	/**
207
-	 * when running the tests wait to let the buckets catch up
208
-	 */
209
-	private function testTimeout() {
210
-		if ($this->test) {
211
-			sleep($this->timeout);
212
-		}
213
-	}
214
-
215
-	public static function legacySignatureProvider($version, $service, $region) {
216
-		switch ($version) {
217
-			case 'v2':
218
-			case 's3':
219
-				return new S3Signature();
220
-			default:
221
-				return null;
222
-		}
223
-	}
224
-
225
-	/**
226
-	 * This function creates a credential provider based on user parameter file
227
-	 */
228
-	protected function paramCredentialProvider(): callable {
229
-		return function () {
230
-			$key = empty($this->params['key']) ? null : $this->params['key'];
231
-			$secret = empty($this->params['secret']) ? null : $this->params['secret'];
232
-			$sessionToken = empty($this->params['session_token']) ? null : $this->params['session_token'];
233
-
234
-			if ($key && $secret) {
235
-				return Create::promiseFor(
236
-					// a null sessionToken match the default signature of the constructor
237
-					new Credentials($key, $secret, $sessionToken)
238
-				);
239
-			}
240
-
241
-			$msg = 'Could not find parameters set for credentials in config file.';
242
-			return new RejectedPromise(new CredentialsException($msg));
243
-		};
244
-	}
245
-
246
-	protected function getCertificateBundlePath(): ?string {
247
-		if ((int)($this->params['use_nextcloud_bundle'] ?? '0')) {
248
-			/** @var ICertificateManager $certManager */
249
-			$certManager = Server::get(ICertificateManager::class);
250
-			// since we store the certificate bundles on the primary storage, we can't get the bundle while setting up the primary storage
251
-			if (!isset($this->params['primary_storage'])) {
252
-				return $certManager->getAbsoluteBundlePath();
253
-			} else {
254
-				return $certManager->getDefaultCertificatesBundlePath();
255
-			}
256
-		} else {
257
-			return null;
258
-		}
259
-	}
260
-
261
-	protected function getSSECKey(): ?string {
262
-		if (isset($this->params['sse_c_key']) && !empty($this->params['sse_c_key'])) {
263
-			return $this->params['sse_c_key'];
264
-		}
265
-
266
-		return null;
267
-	}
268
-
269
-	protected function getSSECParameters(bool $copy = false): array {
270
-		$key = $this->getSSECKey();
271
-
272
-		if ($key === null) {
273
-			return [];
274
-		}
275
-
276
-		$rawKey = base64_decode($key);
277
-		if ($copy) {
278
-			return [
279
-				'CopySourceSSECustomerAlgorithm' => 'AES256',
280
-				'CopySourceSSECustomerKey' => $rawKey,
281
-				'CopySourceSSECustomerKeyMD5' => md5($rawKey, true)
282
-			];
283
-		}
284
-		return [
285
-			'SSECustomerAlgorithm' => 'AES256',
286
-			'SSECustomerKey' => $rawKey,
287
-			'SSECustomerKeyMD5' => md5($rawKey, true)
288
-		];
289
-	}
27
+    use S3ConfigTrait;
28
+
29
+    protected string $id;
30
+
31
+    protected bool $test;
32
+
33
+    protected ?S3Client $connection = null;
34
+
35
+    private ?ICache $existingBucketsCache = null;
36
+
37
+    protected function parseParams($params) {
38
+        if (empty($params['bucket'])) {
39
+            throw new \Exception('Bucket has to be configured.');
40
+        }
41
+
42
+        if (isset($params['multibucket']) && $params['multibucket'] === true && isset($params['perBucket'][$params['bucket']])) {
43
+            $params = array_merge($params, $params['perBucket'][$params['bucket']]);
44
+        }
45
+
46
+        $this->id = 'amazon::' . $params['bucket'];
47
+
48
+        $this->test = isset($params['test']);
49
+        $this->bucket = $params['bucket'];
50
+        // Default to 5 like the S3 SDK does
51
+        $this->concurrency = $params['concurrency'] ?? 5;
52
+        $this->proxy = $params['proxy'] ?? false;
53
+        $this->connectTimeout = $params['connect_timeout'] ?? 5;
54
+        $this->timeout = $params['timeout'] ?? 15;
55
+        $this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
56
+        $this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
57
+        $this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
58
+        $this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
59
+        $this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
60
+        $this->retriesMaxAttempts = $params['retriesMaxAttempts'] ?? 5;
61
+        $params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
62
+        $params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
63
+        $params['s3-accelerate'] = $params['hostname'] === 's3-accelerate.amazonaws.com' || $params['hostname'] === 's3-accelerate.dualstack.amazonaws.com';
64
+        if (!isset($params['port']) || $params['port'] === '') {
65
+            $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
66
+        }
67
+        $params['verify_bucket_exists'] = $params['verify_bucket_exists'] ?? true;
68
+
69
+        if ($params['s3-accelerate']) {
70
+            $params['verify_bucket_exists'] = false;
71
+        }
72
+
73
+        $this->params = $params;
74
+    }
75
+
76
+    public function getBucket() {
77
+        return $this->bucket;
78
+    }
79
+
80
+    public function getProxy() {
81
+        return $this->proxy;
82
+    }
83
+
84
+    /**
85
+     * Returns the connection
86
+     *
87
+     * @return S3Client connected client
88
+     * @throws \Exception if connection could not be made
89
+     */
90
+    public function getConnection() {
91
+        if ($this->connection !== null) {
92
+            return $this->connection;
93
+        }
94
+
95
+        if ($this->existingBucketsCache === null) {
96
+            $this->existingBucketsCache = Server::get(ICacheFactory::class)
97
+                ->createLocal('s3-bucket-exists-cache');
98
+        }
99
+
100
+        $scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https';
101
+        $base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/';
102
+
103
+        // Adding explicit credential provider to the beginning chain.
104
+        // Including default credential provider (skipping AWS shared config files).
105
+        $provider = CredentialProvider::memoize(
106
+            CredentialProvider::chain(
107
+                $this->paramCredentialProvider(),
108
+                CredentialProvider::defaultProvider(['use_aws_shared_config_files' => false])
109
+            )
110
+        );
111
+
112
+        $options = [
113
+            'version' => $this->params['version'] ?? 'latest',
114
+            'credentials' => $provider,
115
+            'endpoint' => $base_url,
116
+            'region' => $this->params['region'],
117
+            'use_path_style_endpoint' => isset($this->params['use_path_style']) ? $this->params['use_path_style'] : false,
118
+            'signature_provider' => \Aws\or_chain([self::class, 'legacySignatureProvider'], ClientResolver::_default_signature_provider()),
119
+            'csm' => false,
120
+            'use_arn_region' => false,
121
+            'http' => [
122
+                'verify' => $this->getCertificateBundlePath(),
123
+                'connect_timeout' => $this->connectTimeout,
124
+            ],
125
+            'use_aws_shared_config_files' => false,
126
+            'retries' => [
127
+                'mode' => 'standard',
128
+                'max_attempts' => $this->retriesMaxAttempts,
129
+            ],
130
+        ];
131
+
132
+        if ($this->params['s3-accelerate']) {
133
+            $options['use_accelerate_endpoint'] = true;
134
+        } else {
135
+            $options['endpoint'] = $base_url;
136
+        }
137
+
138
+        if (isset($this->params['request_checksum_calculation'])) {
139
+            $options['request_checksum_calculation'] = $this->params['request_checksum_calculation'];
140
+        }
141
+
142
+        if (isset($this->params['response_checksum_validation'])) {
143
+            $options['response_checksum_validation'] = $this->params['response_checksum_validation'];
144
+        }
145
+
146
+        if ($this->getProxy()) {
147
+            $options['http']['proxy'] = $this->getProxy();
148
+        }
149
+        if (isset($this->params['legacy_auth']) && $this->params['legacy_auth']) {
150
+            $options['signature_version'] = 'v2';
151
+        }
152
+        $this->connection = new S3Client($options);
153
+
154
+        try {
155
+            $logger = Server::get(LoggerInterface::class);
156
+            if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
157
+                $logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.',
158
+                    ['app' => 'objectstore']);
159
+            }
160
+
161
+            if ($this->params['verify_bucket_exists']) {
162
+                $cacheKey = $this->params['hostname'] . $this->bucket;
163
+                $exist = $this->existingBucketsCache->get($cacheKey) === 1;
164
+
165
+                if (!$exist) {
166
+                    if (!$this->connection->doesBucketExist($this->bucket)) {
167
+                        try {
168
+                            $logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']);
169
+                            if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
170
+                                throw new StorageNotAvailableException('The bucket will not be created because the name is not dns compatible, please correct it: ' . $this->bucket);
171
+                            }
172
+                            $this->connection->createBucket(['Bucket' => $this->bucket]);
173
+                            Server::get(IEventDispatcher::class)
174
+                                ->dispatchTyped(new BucketCreatedEvent(
175
+                                    $this->bucket,
176
+                                    $options['endpoint'],
177
+                                    $options['region'],
178
+                                    $options['version']
179
+                                ));
180
+                            $this->testTimeout();
181
+                        } catch (S3Exception $e) {
182
+                            $logger->debug('Invalid remote storage.', [
183
+                                'exception' => $e,
184
+                                'app' => 'objectstore',
185
+                            ]);
186
+                            if ($e->getAwsErrorCode() !== 'BucketAlreadyOwnedByYou') {
187
+                                throw new StorageNotAvailableException('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());
188
+                            }
189
+                        }
190
+                    }
191
+                    $this->existingBucketsCache->set($cacheKey, 1);
192
+                }
193
+            }
194
+
195
+            // google cloud's s3 compatibility doesn't like the EncodingType parameter
196
+            if (strpos($base_url, 'storage.googleapis.com')) {
197
+                $this->connection->getHandlerList()->remove('s3.auto_encode');
198
+            }
199
+        } catch (S3Exception $e) {
200
+            throw new StorageNotAvailableException('S3 service is unable to handle request: ' . $e->getMessage());
201
+        }
202
+
203
+        return $this->connection;
204
+    }
205
+
206
+    /**
207
+     * when running the tests wait to let the buckets catch up
208
+     */
209
+    private function testTimeout() {
210
+        if ($this->test) {
211
+            sleep($this->timeout);
212
+        }
213
+    }
214
+
215
+    public static function legacySignatureProvider($version, $service, $region) {
216
+        switch ($version) {
217
+            case 'v2':
218
+            case 's3':
219
+                return new S3Signature();
220
+            default:
221
+                return null;
222
+        }
223
+    }
224
+
225
+    /**
226
+     * This function creates a credential provider based on user parameter file
227
+     */
228
+    protected function paramCredentialProvider(): callable {
229
+        return function () {
230
+            $key = empty($this->params['key']) ? null : $this->params['key'];
231
+            $secret = empty($this->params['secret']) ? null : $this->params['secret'];
232
+            $sessionToken = empty($this->params['session_token']) ? null : $this->params['session_token'];
233
+
234
+            if ($key && $secret) {
235
+                return Create::promiseFor(
236
+                    // a null sessionToken match the default signature of the constructor
237
+                    new Credentials($key, $secret, $sessionToken)
238
+                );
239
+            }
240
+
241
+            $msg = 'Could not find parameters set for credentials in config file.';
242
+            return new RejectedPromise(new CredentialsException($msg));
243
+        };
244
+    }
245
+
246
+    protected function getCertificateBundlePath(): ?string {
247
+        if ((int)($this->params['use_nextcloud_bundle'] ?? '0')) {
248
+            /** @var ICertificateManager $certManager */
249
+            $certManager = Server::get(ICertificateManager::class);
250
+            // since we store the certificate bundles on the primary storage, we can't get the bundle while setting up the primary storage
251
+            if (!isset($this->params['primary_storage'])) {
252
+                return $certManager->getAbsoluteBundlePath();
253
+            } else {
254
+                return $certManager->getDefaultCertificatesBundlePath();
255
+            }
256
+        } else {
257
+            return null;
258
+        }
259
+    }
260
+
261
+    protected function getSSECKey(): ?string {
262
+        if (isset($this->params['sse_c_key']) && !empty($this->params['sse_c_key'])) {
263
+            return $this->params['sse_c_key'];
264
+        }
265
+
266
+        return null;
267
+    }
268
+
269
+    protected function getSSECParameters(bool $copy = false): array {
270
+        $key = $this->getSSECKey();
271
+
272
+        if ($key === null) {
273
+            return [];
274
+        }
275
+
276
+        $rawKey = base64_decode($key);
277
+        if ($copy) {
278
+            return [
279
+                'CopySourceSSECustomerAlgorithm' => 'AES256',
280
+                'CopySourceSSECustomerKey' => $rawKey,
281
+                'CopySourceSSECustomerKeyMD5' => md5($rawKey, true)
282
+            ];
283
+        }
284
+        return [
285
+            'SSECustomerAlgorithm' => 'AES256',
286
+            'SSECustomerKey' => $rawKey,
287
+            'SSECustomerKeyMD5' => md5($rawKey, true)
288
+        ];
289
+    }
290 290
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 			$params = array_merge($params, $params['perBucket'][$params['bucket']]);
44 44
 		}
45 45
 
46
-		$this->id = 'amazon::' . $params['bucket'];
46
+		$this->id = 'amazon::'.$params['bucket'];
47 47
 
48 48
 		$this->test = isset($params['test']);
49 49
 		$this->bucket = $params['bucket'];
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 		$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
57 57
 		$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
58 58
 		$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
59
-		$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
59
+		$this->useMultipartCopy = (bool) ($params['useMultipartCopy'] ?? true);
60 60
 		$this->retriesMaxAttempts = $params['retriesMaxAttempts'] ?? 5;
61 61
 		$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
62
-		$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
62
+		$params['hostname'] = empty($params['hostname']) ? 's3.'.$params['region'].'.amazonaws.com' : $params['hostname'];
63 63
 		$params['s3-accelerate'] = $params['hostname'] === 's3-accelerate.amazonaws.com' || $params['hostname'] === 's3-accelerate.dualstack.amazonaws.com';
64 64
 		if (!isset($params['port']) || $params['port'] === '') {
65 65
 			$params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		}
99 99
 
100 100
 		$scheme = (isset($this->params['use_ssl']) && $this->params['use_ssl'] === false) ? 'http' : 'https';
101
-		$base_url = $scheme . '://' . $this->params['hostname'] . ':' . $this->params['port'] . '/';
101
+		$base_url = $scheme.'://'.$this->params['hostname'].':'.$this->params['port'].'/';
102 102
 
103 103
 		// Adding explicit credential provider to the beginning chain.
104 104
 		// Including default credential provider (skipping AWS shared config files).
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 		try {
155 155
 			$logger = Server::get(LoggerInterface::class);
156 156
 			if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
157
-				$logger->debug('Bucket "' . $this->bucket . '" This bucket name is not dns compatible, it may contain invalid characters.',
157
+				$logger->debug('Bucket "'.$this->bucket.'" This bucket name is not dns compatible, it may contain invalid characters.',
158 158
 					['app' => 'objectstore']);
159 159
 			}
160 160
 
161 161
 			if ($this->params['verify_bucket_exists']) {
162
-				$cacheKey = $this->params['hostname'] . $this->bucket;
162
+				$cacheKey = $this->params['hostname'].$this->bucket;
163 163
 				$exist = $this->existingBucketsCache->get($cacheKey) === 1;
164 164
 
165 165
 				if (!$exist) {
166 166
 					if (!$this->connection->doesBucketExist($this->bucket)) {
167 167
 						try {
168
-							$logger->info('Bucket "' . $this->bucket . '" does not exist - creating it.', ['app' => 'objectstore']);
168
+							$logger->info('Bucket "'.$this->bucket.'" does not exist - creating it.', ['app' => 'objectstore']);
169 169
 							if (!$this->connection::isBucketDnsCompatible($this->bucket)) {
170
-								throw new StorageNotAvailableException('The bucket will not be created because the name is not dns compatible, please correct it: ' . $this->bucket);
170
+								throw new StorageNotAvailableException('The bucket will not be created because the name is not dns compatible, please correct it: '.$this->bucket);
171 171
 							}
172 172
 							$this->connection->createBucket(['Bucket' => $this->bucket]);
173 173
 							Server::get(IEventDispatcher::class)
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 								'app' => 'objectstore',
185 185
 							]);
186 186
 							if ($e->getAwsErrorCode() !== 'BucketAlreadyOwnedByYou') {
187
-								throw new StorageNotAvailableException('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());
187
+								throw new StorageNotAvailableException('Creation of bucket "'.$this->bucket.'" failed. '.$e->getMessage());
188 188
 							}
189 189
 						}
190 190
 					}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				$this->connection->getHandlerList()->remove('s3.auto_encode');
198 198
 			}
199 199
 		} catch (S3Exception $e) {
200
-			throw new StorageNotAvailableException('S3 service is unable to handle request: ' . $e->getMessage());
200
+			throw new StorageNotAvailableException('S3 service is unable to handle request: '.$e->getMessage());
201 201
 		}
202 202
 
203 203
 		return $this->connection;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * This function creates a credential provider based on user parameter file
227 227
 	 */
228 228
 	protected function paramCredentialProvider(): callable {
229
-		return function () {
229
+		return function() {
230 230
 			$key = empty($this->params['key']) ? null : $this->params['key'];
231 231
 			$secret = empty($this->params['secret']) ? null : $this->params['secret'];
232 232
 			$sessionToken = empty($this->params['session_token']) ? null : $this->params['session_token'];
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	}
245 245
 
246 246
 	protected function getCertificateBundlePath(): ?string {
247
-		if ((int)($this->params['use_nextcloud_bundle'] ?? '0')) {
247
+		if ((int) ($this->params['use_nextcloud_bundle'] ?? '0')) {
248 248
 			/** @var ICertificateManager $certManager */
249 249
 			$certManager = Server::get(ICertificateManager::class);
250 250
 			// since we store the certificate bundles on the primary storage, we can't get the bundle while setting up the primary storage
Please login to merge, or discard this patch.