Skip to content

Commit b1a724b

Browse files
committed
bucket notifications - wrong etag, size (#8819)
Signed-off-by: Amit Prinz Setter <alphaprinz@gmail.com>
1 parent fa59a2b commit b1a724b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/endpoint/s3/ops/s3_put_object.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ async function put_object(req, res) {
6565
}
6666
s3_utils.set_encryption_response_headers(req, res, reply.encryption);
6767

68+
res.size_for_notif = size || reply.size;
69+
6870
if (copy_source) {
6971
// TODO: This needs to be checked regarding copy between diff namespaces
7072
// In that case we do not have the copy_source property and just read and upload the stream

src/sdk/namespace_fs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2507,7 +2507,8 @@ class NamespaceFS {
25072507
return {
25082508
etag,
25092509
encryption,
2510-
version_id
2510+
version_id,
2511+
size: stat.size
25112512
};
25122513
}
25132514

src/util/notifications_util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ function compose_notification_req(req, res, bucket, notif_conf) {
423423
let eTag = res.getHeader('ETag');
424424
//eslint-disable-next-line
425425
if (eTag && eTag.startsWith('\"') && eTag.endsWith('\"')) {
426-
eTag = eTag.substring(2, eTag.length - 2);
426+
eTag = eTag.substring(1, eTag.length - 1);
427427
}
428428

429429
const event = OP_TO_EVENT[req.op_name];
@@ -443,7 +443,7 @@ function compose_notification_req(req, res, bucket, notif_conf) {
443443
"x-amz-id-2": req.request_id,
444444
};
445445
notif.s3.object.key = req.params.key;
446-
notif.s3.object.size = res.getHeader('content-length');
446+
notif.s3.object.size = res.size_for_notif;
447447
notif.s3.object.eTag = eTag;
448448
notif.s3.object.versionId = res.getHeader('x-amz-version-id');
449449

@@ -463,6 +463,8 @@ function compose_notification_req(req, res, bucket, notif_conf) {
463463
notif.s3.object.sequencer = res.seq;
464464
}
465465

466+
delete res.size_for_notif;
467+
466468
return compose_meta(notif, notif_conf, bucket);
467469
}
468470

0 commit comments

Comments
 (0)