diff --git a/AwsS3V3Adapter.php b/AwsS3V3Adapter.php index 9b87d8c..9e35a50 100644 --- a/AwsS3V3Adapter.php +++ b/AwsS3V3Adapter.php @@ -415,8 +415,11 @@ public function move(string $source, string $destination, Config $config): void public function copy(string $source, string $destination, Config $config): void { try { - /** @var string $visibility */ - $visibility = $config->get(Config::OPTION_VISIBILITY) ?: $this->visibility($source)->visibility(); + $visibility = $config->get(Config::OPTION_VISIBILITY); + + if ($visibility === null && $config->get('retain_visibility', true)) { + $visibility = $this->visibility($source)->visibility(); + } } catch (Throwable $exception) { throw UnableToCopyFile::fromLocationTo( $source, @@ -431,7 +434,7 @@ public function copy(string $source, string $destination, Config $config): void $this->prefixer->prefixPath($source), $this->bucket, $this->prefixer->prefixPath($destination), - $this->visibility->visibilityToAcl($visibility), + $this->visibility->visibilityToAcl($visibility ?: 'private'), $this->createOptionsFromConfig($config)['params'] ); } catch (Throwable $exception) {