Skip to content

Commit

Permalink
added mup options to config array
Browse files Browse the repository at this point in the history
  • Loading branch information
ToshY authored and frankdejonge committed Jan 15, 2022
1 parent 03592e7 commit 1535e21
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/AwsS3V3/AwsS3V3Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
*/
Expand Down Expand Up @@ -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);
}
Expand All @@ -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__') {
Expand Down

0 comments on commit 1535e21

Please sign in to comment.