mirror of
https://github.com/nextcloud/server.git
synced 2026-03-01 13:00:44 -05:00
fix: encode s3 metadata as base64 if needed
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
b797d10465
commit
d2b176fee8
2 changed files with 8 additions and 1 deletions
|
|
@ -100,6 +100,9 @@ class S3 implements IObjectStore, IObjectStoreMultiPartUpload, IObjectStoreMetaD
|
|||
$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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,11 @@ trait S3ObjectTrait {
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue