Przeglądaj źródła

Merge pull request #44496 from nextcloud/feat/s3-accelerate

feat: support "s3-accelerate" endpoint
pull/44670/head
Robin Appelman 3 tygodni temu
rodzic
commit
a2fefbce9a
No account linked to committer's email address
1 zmienionych plików z 16 dodań i 1 usunięć
  1. 16
    1
      lib/private/Files/ObjectStore/S3ConnectionTrait.php

+ 16
- 1
lib/private/Files/ObjectStore/S3ConnectionTrait.php Wyświetl plik

@@ -71,11 +71,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;
}

@@ -122,6 +128,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();
}
@@ -150,7 +163,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());
}
}
}


Ładowanie…
Anuluj
Zapisz