From 1535e2116c612205381437b3214d86bedcf0a7e5 Mon Sep 17 00:00:00 2001 From: ToshY <31921460+ToshY@users.noreply.github.com> Date: Wed, 5 Jan 2022 14:05:05 +0100 Subject: [PATCH] added mup options to config array --- src/AwsS3V3/AwsS3V3Adapter.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/AwsS3V3/AwsS3V3Adapter.php b/src/AwsS3V3/AwsS3V3Adapter.php index 157eb09a5..b0309d73c 100644 --- a/src/AwsS3V3/AwsS3V3Adapter.php +++ b/src/AwsS3V3/AwsS3V3Adapter.php @@ -60,6 +60,17 @@ class AwsS3V3Adapter implements FilesystemAdapter 'Tagging', 'WebsiteRedirectLocation', ]; + /** + * @var string[] + */ + public const MUP_AVAILABLE_OPTIONS = [ + 'before_upload', + 'concurrency', + 'mup_threshold', + 'params', + 'part_size', + ]; + /** * @var string[] */ @@ -160,14 +171,14 @@ private function upload(string $path, $body, Config $config): void $key = $this->prefixer->prefixPath($path); $options = $this->createOptionsFromConfig($config); $acl = $options['ACL'] ?? $this->determineAcl($config); - $shouldDetermineMimetype = $body !== '' && ! array_key_exists('ContentType', $options); + $shouldDetermineMimetype = $body !== '' && ! array_key_exists('ContentType', $options['params']); if ($shouldDetermineMimetype && $mimeType = $this->mimeTypeDetector->detectMimeType($key, $body)) { - $options['ContentType'] = $mimeType; + $options['params']['ContentType'] = $mimeType; } try { - $this->client->upload($this->bucket, $key, $body, $acl, ['params' => $options]); + $this->client->upload($this->bucket, $key, $body, $acl, $options); } catch (Throwable $exception) { throw UnableToWriteFile::atLocation($path, '', $exception); } @@ -182,9 +193,9 @@ private function determineAcl(Config $config): string private function createOptionsFromConfig(Config $config): array { - $options = []; + $options = ['params' => []]; - foreach (static::AVAILABLE_OPTIONS as $option) { + foreach (array_merge(static::AVAILABLE_OPTIONS, static::MUP_AVAILABLE_OPTIONS) as $option) { $value = $config->get($option, '__NOT_SET__'); if ($value !== '__NOT_SET__') {