From 28c5a887de28273e0a9605d7d4b77b84912ed876 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 30 Mar 2017 08:58:14 -0700 Subject: [PATCH] event: Set contentType as well under NotificationEvent. (#4003) This is an enhancement change to to cater support all the data fields present on the object. Currently we only send a subset of data which object info provides us. It also helps us keep a full namespace mirror on notification targets for efficient query. --- cmd/bucket-notification-datatypes.go | 12 +++++++----- cmd/event-notifier.go | 12 ++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/cmd/bucket-notification-datatypes.go b/cmd/bucket-notification-datatypes.go index 7f7aec6e6..3be763e37 100644 --- a/cmd/bucket-notification-datatypes.go +++ b/cmd/bucket-notification-datatypes.go @@ -136,11 +136,13 @@ type bucketMeta struct { // Notification event object metadata. type objectMeta struct { - Key string `json:"key"` - Size int64 `json:"size,omitempty"` - ETag string `json:"eTag,omitempty"` - VersionID string `json:"versionId,omitempty"` - Sequencer string `json:"sequencer"` + Key string `json:"key"` + Size int64 `json:"size,omitempty"` + ETag string `json:"eTag,omitempty"` + ContentType string `json:"contentType:omitempty"` + UserDefined map[string]string `json:"userDefined:omitempty"` + VersionID string `json:"versionId,omitempty"` + Sequencer string `json:"sequencer"` } const ( diff --git a/cmd/event-notifier.go b/cmd/event-notifier.go index 687748c1a..b38c4c053 100644 --- a/cmd/event-notifier.go +++ b/cmd/event-notifier.go @@ -156,6 +156,7 @@ func newNotificationEvent(event eventData) NotificationEvent { if event.Type == ObjectRemovedDelete { nEvent.S3.Object = objectMeta{ Key: escapedObj, + VersionID: "1", Sequencer: uniqueID, } return nEvent @@ -163,10 +164,13 @@ func newNotificationEvent(event eventData) NotificationEvent { // For all other events we should set ETag and Size. nEvent.S3.Object = objectMeta{ - Key: escapedObj, - ETag: event.ObjInfo.MD5Sum, - Size: event.ObjInfo.Size, - Sequencer: uniqueID, + Key: escapedObj, + ETag: event.ObjInfo.MD5Sum, + Size: event.ObjInfo.Size, + ContentType: event.ObjInfo.ContentType, + UserDefined: event.ObjInfo.UserDefined, + VersionID: "1", + Sequencer: uniqueID, } // Success.