Cannot open encrypted files on Amazon S3 storage

[/details]

Nextcloud version (eg, 20.0.5): 28.0.5
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04.3
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.52
PHP version (eg, 7.4): 8.1.2

The issue you are facing:
I have files that are stored on Amazon S3 storage with server side encryption enabled. Files that are older than says 3-4 years cannot be opened. They seem not to be properly decrypted. When downloading them I cannot open them.

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

{"reqId":"lfxzq1TDwWUqzu94RMqn","level":3,"time":"2024-05-02T15:31:51+00:00","remoteAddr":"xx.xx.xx.xx","user":"username","app":"PHP","method":"GET","url":"/remote.php/dav/files/username/path/to/file.jpg","message":"Array to string conversion at /var/www/nextcloud/lib/private/Files/Cache/Scanner.php#224","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0","version":"28.0.5.1","data":{"app":"PHP"}}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => '',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => 'xxx.xxx.xxx.xxx',
    1 => 'path.to.nextcloud',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '28.0.5.1',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'default_phone_region' => 'NL',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),
  'maintenance' => false,
  'maintenance_window_start' => 1,
  'theme' => '',
  'loglevel' => 2,
  'session_keepalive' => false,
  'session_lifetime' => 600,
  'updater.release.channel' => 'stable',
  'twofactor_enforced' => 'false',
  'twofactor_enforced_groups' => 
  array (
  ),
  'twofactor_enforced_excluded_groups' => 
  array (
  ),
  'mysql.utf8mb4' => true,
  'app_install_overwrite' => 
  array (
    0 => 'calendar',
    1 => 'spreed',
    2 => 'twofactor_totp',
  ),
  'encryption.key_storage_migrated' => false,
  'updater.secret' => ,
);