Parcourir la source

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

feat: support "s3-accelerate" endpoint
pull/44670/head
Robin Appelman il y a 1 mois
Parent
révision
a2fefbce9a
Aucun compte lié à l'adresse e-mail de l'auteur
1 fichiers modifiés avec 16 ajouts et 1 suppressions
  1. 16
    1
      lib/private/Files/ObjectStore/S3ConnectionTrait.php

+ 16
- 1
lib/private/Files/ObjectStore/S3ConnectionTrait.php Voir le fichier

$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000; $this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true); $this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region']; $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']; $params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
if (!isset($params['port']) || $params['port'] === '') { if (!isset($params['port']) || $params['port'] === '') {
$params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443; $params['port'] = (isset($params['use_ssl']) && $params['use_ssl'] === false) ? 80 : 443;
} }
$params['verify_bucket_exists'] = $params['verify_bucket_exists'] ?? true; $params['verify_bucket_exists'] = $params['verify_bucket_exists'] ?? true;

if ($params['s3-accelerate']) {
$params['verify_bucket_exists'] = false;
}

$this->params = $params; $this->params = $params;
} }


'http' => ['verify' => $this->getCertificateBundlePath()], 'http' => ['verify' => $this->getCertificateBundlePath()],
'use_aws_shared_config_files' => false, 'use_aws_shared_config_files' => false,
]; ];

if ($this->params['s3-accelerate']) {
$options['use_accelerate_endpoint'] = true;
} else {
$options['endpoint'] = $base_url;
}

if ($this->getProxy()) { if ($this->getProxy()) {
$options['http']['proxy'] = $this->getProxy(); $options['http']['proxy'] = $this->getProxy();
} }
'exception' => $e, 'exception' => $e,
'app' => 'objectstore', '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());
}
} }
} }



Chargement…
Annuler
Enregistrer