diff --git a/lib/private/Files/ObjectStore/ObjectStoreStorage.php b/lib/private/Files/ObjectStore/ObjectStoreStorage.php index 323da62ce46b0..8ce992e93c050 100644 --- a/lib/private/Files/ObjectStore/ObjectStoreStorage.php +++ b/lib/private/Files/ObjectStore/ObjectStoreStorage.php @@ -480,7 +480,7 @@ public function writeStream(string $path, $stream, ?int $size = null): int { $metadata = [ 'mimetype' => $mimetype, 'original-storage' => $this->getId(), - 'original-path' => rawurlencode($path), + 'original-path' => $path, ]; if ($size) { $metadata['size'] = $size; diff --git a/lib/private/Files/ObjectStore/S3.php b/lib/private/Files/ObjectStore/S3.php index 72e1751e23d3c..e92346e4ccc01 100644 --- a/lib/private/Files/ObjectStore/S3.php +++ b/lib/private/Files/ObjectStore/S3.php @@ -100,6 +100,9 @@ private function parseS3Metadata(array $metadata): array { $result = []; foreach ($metadata as $key => $value) { if (str_starts_with($key, 'x-amz-meta-')) { + if (str_starts_with($value, 'base64:')) { + $value = base64_decode(substr($value, 7)); + } $result[substr($key, strlen('x-amz-meta-'))] = $value; } } diff --git a/lib/private/Files/ObjectStore/S3ObjectTrait.php b/lib/private/Files/ObjectStore/S3ObjectTrait.php index 9362609fa5ad2..f47a01dab18b3 100644 --- a/lib/private/Files/ObjectStore/S3ObjectTrait.php +++ b/lib/private/Files/ObjectStore/S3ObjectTrait.php @@ -82,7 +82,11 @@ public function readObject($urn) { private function buildS3Metadata(array $metadata): array { $result = []; foreach ($metadata as $key => $value) { - $result['x-amz-meta-' . $key] = $value; + if (mb_check_encoding($value, 'ASCII')) { + $result['x-amz-meta-' . $key] = $value; + } else { + $result['x-amz-meta-' . $key] = 'base64:' . base64_encode($value); + } } return $result; }