mirror of
https://github.com/nextcloud/server.git
synced 2026-06-19 13:39:40 -04:00
feat(ObjectStore): Make S3 MultipartUpload concurrency configurable
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
69c5e8ebde
commit
32dee2f84a
3 changed files with 9 additions and 3 deletions
|
|
@ -34,6 +34,9 @@ trait S3ConfigTrait {
|
|||
|
||||
protected string $bucket;
|
||||
|
||||
/** Maximum number of concurrent multipart uploads */
|
||||
protected int $concurrency;
|
||||
|
||||
protected int $timeout;
|
||||
|
||||
protected string $proxy;
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ trait S3ConnectionTrait {
|
|||
|
||||
protected string $id;
|
||||
|
||||
protected ?S3Client $connection;
|
||||
|
||||
protected bool $test;
|
||||
|
||||
protected ?S3Client $connection = null;
|
||||
|
||||
protected function parseParams($params) {
|
||||
if (empty($params['bucket'])) {
|
||||
throw new \Exception("Bucket has to be configured.");
|
||||
|
|
@ -61,6 +61,8 @@ trait S3ConnectionTrait {
|
|||
|
||||
$this->test = isset($params['test']);
|
||||
$this->bucket = $params['bucket'];
|
||||
// Default to 5 like the S3 SDK does
|
||||
$this->concurrency = $params['concurrency'] ?? 5;
|
||||
$this->proxy = $params['proxy'] ?? false;
|
||||
$this->timeout = $params['timeout'] ?? 15;
|
||||
$this->storageClass = !empty($params['storageClass']) ? $params['storageClass'] : 'STANDARD';
|
||||
|
|
@ -92,7 +94,7 @@ trait S3ConnectionTrait {
|
|||
* @throws \Exception if connection could not be made
|
||||
*/
|
||||
public function getConnection() {
|
||||
if (!is_null($this->connection)) {
|
||||
if ($this->connection !== null) {
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ trait S3ObjectTrait {
|
|||
protected function writeMultiPart(string $urn, StreamInterface $stream, string $mimetype = null): void {
|
||||
$uploader = new MultipartUploader($this->getConnection(), $stream, [
|
||||
'bucket' => $this->bucket,
|
||||
'concurrency' => $this->concurrency,
|
||||
'key' => $urn,
|
||||
'part_size' => $this->uploadPartSize,
|
||||
'params' => [
|
||||
|
|
|
|||
Loading…
Reference in a new issue