fix(s3): Add config option to disable multipart copy for certain s3 providers

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2023-12-28 15:31:08 +01:00 committed by backportbot-nextcloud[bot]
parent 58abe5e3f4
commit 238ea7a8b4
2 changed files with 4 additions and 1 deletions

View file

@ -74,6 +74,8 @@ trait S3ConnectionTrait {
/** @var int */
private $copySizeLimit;
private bool $useMultipartCopy = true;
protected $test;
protected function parseParams($params) {
@ -91,6 +93,7 @@ trait S3ConnectionTrait {
$this->uploadPartSize = $params['uploadPartSize'] ?? 524288000;
$this->putSizeLimit = $params['putSizeLimit'] ?? 104857600;
$this->copySizeLimit = $params['copySizeLimit'] ?? 5242880000;
$this->useMultipartCopy = (bool)($params['useMultipartCopy'] ?? true);
$params['region'] = empty($params['region']) ? 'eu-west-1' : $params['region'];
$params['hostname'] = empty($params['hostname']) ? 's3.' . $params['region'] . '.amazonaws.com' : $params['hostname'];
if (!isset($params['port']) || $params['port'] === '') {

View file

@ -198,7 +198,7 @@ trait S3ObjectTrait {
$size = (int)($sourceMetadata->get('Size') ?? $sourceMetadata->get('ContentLength'));
if ($size > $this->copySizeLimit) {
if ($this->useMultipartCopy && $size > $this->copySizeLimit) {
$copy = new MultipartCopy($this->getConnection(), [
"source_bucket" => $this->getBucket(),
"source_key" => $from