Ensure actual object size is sent in notification (#8418)

Fixes: #8407
master
poornas 5 years ago committed by Harshavardhana
parent 7bf093c06a
commit 1b74ce3924
  1. 9
      cmd/notification.go
  2. 8
      cmd/object-handlers.go

@ -1191,6 +1191,15 @@ func (args eventArgs) ToEvent() event.Event {
func sendEvent(args eventArgs) { func sendEvent(args eventArgs) {
// remove sensitive encryption entries in metadata. // remove sensitive encryption entries in metadata.
switch {
case crypto.IsEncrypted(args.Object.UserDefined):
if totalObjectSize, err := args.Object.DecryptedSize(); err == nil {
args.Object.Size = totalObjectSize
}
case args.Object.IsCompressed():
args.Object.Size = args.Object.GetActualSize()
}
crypto.RemoveSensitiveEntries(args.Object.UserDefined) crypto.RemoveSensitiveEntries(args.Object.UserDefined)
crypto.RemoveInternalEntries(args.Object.UserDefined) crypto.RemoveInternalEntries(args.Object.UserDefined)

@ -1272,7 +1272,6 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
if objectAPI.IsEncryptionSupported() { if objectAPI.IsEncryptionSupported() {
if crypto.IsEncrypted(objInfo.UserDefined) { if crypto.IsEncrypted(objInfo.UserDefined) {
objInfo.Size, _ = objInfo.DecryptedSize()
switch { switch {
case crypto.S3.IsEncrypted(objInfo.UserDefined): case crypto.S3.IsEncrypted(objInfo.UserDefined):
w.Header().Set(crypto.SSEHeader, crypto.SSEAlgorithmAES256) w.Header().Set(crypto.SSEHeader, crypto.SSEAlgorithmAES256)
@ -2337,13 +2336,6 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
// Write success response. // Write success response.
writeSuccessResponseXML(w, encodedSuccessResponse) writeSuccessResponseXML(w, encodedSuccessResponse)
// Get host and port from Request.RemoteAddr.
if objectAPI.IsEncryptionSupported() {
if crypto.IsEncrypted(objInfo.UserDefined) {
objInfo.Size, _ = objInfo.DecryptedSize()
}
}
// Notify object created event. // Notify object created event.
sendEvent(eventArgs{ sendEvent(eventArgs{
EventName: event.ObjectCreatedCompleteMultipartUpload, EventName: event.ObjectCreatedCompleteMultipartUpload,

Loading…
Cancel
Save