summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-03-26 15:47:14 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-04-26 14:46:15 +0000
commita1db2021ee726102578b6e7d0249e35c8251e1df (patch)
tree3a9c13425a5eb95610e0546a85dd3787aa9707e8 /lib
parent3cc5b6591e935e301c454ebcc799b191ad6c1797 (diff)
downloadnextcloud-server-a1db2021ee726102578b6e7d0249e35c8251e1df.tar.gz
nextcloud-server-a1db2021ee726102578b6e7d0249e35c8251e1df.zip
feat: add option to enable s3 acceleration
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Files/ObjectStore/S3ConnectionTrait.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/private/Files/ObjectStore/S3ConnectionTrait.php b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
index e6ed9c2ef5b..02045ca1775 100644
--- a/lib/private/Files/ObjectStore/S3ConnectionTrait.php
+++ b/lib/private/Files/ObjectStore/S3ConnectionTrait.php
@@ -95,11 +95,17 @@ trait S3ConnectionTrait {
$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
+ $params['s3-accelerate'] = $params['hostname'] == 's3-accelerate.amazonaws.com' || $params['hostname'] == 's3-accelerate.dualstack.amazonaws.com';
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
if (!isset($params['port']) || $params['port'] === '') {
$params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
}
$params['verify_bucket_exists'] = $params['verify_bucket_exists'] ?? true;
+
+ if ($params['s3-accelerate']) {
+ $params['verify_bucket_exists'] = false;
+ }
+
$this->params = $params;
}
@@ -146,6 +152,13 @@ trait S3ConnectionTrait {
'http' => ['verify' => $this->getCertificateBundlePath()],
'use_aws_shared_config_files' => false,
];
+
+ if ($this->params['s3-accelerate']) {
+ $options['use_accelerate_endpoint'] = true;
+ } else {
+ $options['endpoint'] = $base_url;
+ }
+
if ($this->getProxy()) {
$options['http']['proxy'] = $this->getProxy();
}
@@ -174,7 +187,9 @@ trait S3ConnectionTrait {
'exception' => $e,
'app' => 'objectstore',
]);
- throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());
+ if ($e->getAwsErrorCode() !== "BucketAlreadyOwnedByYou") {
+ throw new \Exception('Creation of bucket "' . $this->bucket . '" failed. ' . $e->getMessage());
+ }
}
}