@ -23,6 +23,7 @@ import (
"io/ioutil"
"io/ioutil"
"net/http"
"net/http"
"net/url"
"net/url"
"path"
"sort"
"sort"
"strconv"
"strconv"
"strings"
"strings"
@ -357,13 +358,18 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
// Load notification config if any.
// Load notification config if any.
nConfig , err := api . loadNotificationConfig ( bucket )
nConfig , err := api . loadNotificationConfig ( bucket )
// Notifications not set, return.
if err == errNoSuchNotifications {
return
}
// For all other errors, return.
if err != nil {
if err != nil {
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
return
return
}
}
// Notify object created event.
// Notify object created event.
notifyObjectCreatedEvent ( nConfig , ObjectCreatedCopy , bucket , object , obj Info . MD5Sum , objInfo . Size )
notifyObjectCreatedEvent ( nConfig , ObjectCreatedCopy , bucket , objInfo )
}
}
// PutObjectHandler - PUT Object
// PutObjectHandler - PUT Object
@ -436,13 +442,25 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
// Load notification config if any.
// Load notification config if any.
nConfig , err := api . loadNotificationConfig ( bucket )
nConfig , err := api . loadNotificationConfig ( bucket )
// Notifications not set, return.
if err == errNoSuchNotifications {
return
}
// For all other errors return.
if err != nil {
if err != nil {
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
return
return
}
}
// Fetch object info for notifications.
objInfo , err := api . ObjectAPI . GetObjectInfo ( bucket , object )
if err != nil {
errorIf ( err , "Unable to fetch object info for \"%s\"" , path . Join ( bucket , object ) )
return
}
// Notify object created event.
// Notify object created event.
notifyObjectCreatedEvent ( nConfig , ObjectCreatedPut , bucket , object , md5Sum , size )
notifyObjectCreatedEvent ( nConfig , ObjectCreatedPut , bucket , objInfo )
}
}
/// Multipart objectAPIHandlers
/// Multipart objectAPIHandlers
@ -761,14 +779,25 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
// Load notification config if any.
// Load notification config if any.
nConfig , err := api . loadNotificationConfig ( bucket )
nConfig , err := api . loadNotificationConfig ( bucket )
// Notifications not set, return.
if err == errNoSuchNotifications {
return
}
// For all other errors.
if err != nil {
if err != nil {
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
return
return
}
}
// Fetch object info for notifications.
objInfo , err := api . ObjectAPI . GetObjectInfo ( bucket , object )
if err != nil {
errorIf ( err , "Unable to fetch object info for \"%s\"" , path . Join ( bucket , object ) )
return
}
// Notify object created event.
// Notify object created event.
size := int64 ( 0 ) // FIXME: support event size.
notifyObjectCreatedEvent ( nConfig , ObjectCreatedCompleteMultipartUpload , bucket , objInfo )
notifyObjectCreatedEvent ( nConfig , ObjectCreatedCompleteMultipartUpload , bucket , object , md5Sum , size )
}
}
/// Delete objectAPIHandlers
/// Delete objectAPIHandlers
@ -807,6 +836,11 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
// Load notification config if any.
// Load notification config if any.
nConfig , err := api . loadNotificationConfig ( bucket )
nConfig , err := api . loadNotificationConfig ( bucket )
// Notifications not set, return.
if err == errNoSuchNotifications {
return
}
// For all other errors, return.
if err != nil {
if err != nil {
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
errorIf ( err , "Unable to load notification config for bucket: \"%s\"" , bucket )
return
return