From fdf46172fe7e6fac3313889535065c462a3e0cff Mon Sep 17 00:00:00 2001 From: Amit Prinz Setter Date: Thu, 20 Feb 2025 10:27:46 -0800 Subject: [PATCH] bucket notifications - wrong etag, size Signed-off-by: Amit Prinz Setter --- src/endpoint/s3/ops/s3_put_object.js | 2 ++ src/sdk/namespace_fs.js | 3 ++- src/util/notifications_util.js | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/endpoint/s3/ops/s3_put_object.js b/src/endpoint/s3/ops/s3_put_object.js index c6efd66177..ed2b243bd4 100644 --- a/src/endpoint/s3/ops/s3_put_object.js +++ b/src/endpoint/s3/ops/s3_put_object.js @@ -65,6 +65,8 @@ async function put_object(req, res) { } s3_utils.set_encryption_response_headers(req, res, reply.encryption); + res.size_for_notif = size || reply.size; + if (copy_source) { // TODO: This needs to be checked regarding copy between diff namespaces // In that case we do not have the copy_source property and just read and upload the stream diff --git a/src/sdk/namespace_fs.js b/src/sdk/namespace_fs.js index e9834e8941..bccff32cda 100644 --- a/src/sdk/namespace_fs.js +++ b/src/sdk/namespace_fs.js @@ -2540,7 +2540,8 @@ class NamespaceFS { return { etag, encryption, - version_id + version_id, + size: stat.size }; } diff --git a/src/util/notifications_util.js b/src/util/notifications_util.js index a61fdbd43c..e2386a061b 100644 --- a/src/util/notifications_util.js +++ b/src/util/notifications_util.js @@ -422,7 +422,7 @@ function compose_notification_req(req, res, bucket, notif_conf) { let eTag = res.getHeader('ETag'); //eslint-disable-next-line if (eTag && eTag.startsWith('\"') && eTag.endsWith('\"')) { - eTag = eTag.substring(2, eTag.length - 2); + eTag = eTag.substring(1, eTag.length - 1); } const event = OP_TO_EVENT[req.op_name]; @@ -442,7 +442,7 @@ function compose_notification_req(req, res, bucket, notif_conf) { "x-amz-id-2": req.request_id, }; notif.s3.object.key = req.params.key; - notif.s3.object.size = res.getHeader('content-length'); + notif.s3.object.size = res.size_for_notif; notif.s3.object.eTag = eTag; notif.s3.object.versionId = res.getHeader('x-amz-version-id'); @@ -462,6 +462,8 @@ function compose_notification_req(req, res, bucket, notif_conf) { notif.s3.object.sequencer = res.seq; } + delete res.size_for_notif; + return compose_meta(notif, notif_conf, bucket); }