[#357] Add ObjectCreated notifications
Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
parent
67c1ba2c61
commit
b7aac223df
3 changed files with 40 additions and 0 deletions
|
@ -133,6 +133,16 @@ func (h *handler) CopyObjectHandler(w http.ResponseWriter, r *http.Request) {
|
|||
zap.String("bucket", info.Bucket),
|
||||
zap.String("object", info.Name),
|
||||
zap.Stringer("object_id", info.ID))
|
||||
|
||||
s := &layer.SendNotificationParams{
|
||||
Event: layer.EventObjectCreatedCopy,
|
||||
ObjInfo: info,
|
||||
BktInfo: dstBktInfo,
|
||||
ReqInfo: reqInfo,
|
||||
}
|
||||
if err := h.obj.SendNotifications(r.Context(), s); err != nil {
|
||||
h.log.Error("couldn't send notification: %w", zap.Error(err))
|
||||
}
|
||||
}
|
||||
|
||||
func parseCopyObjectArgs(headers http.Header) (*copyObjectArgs, error) {
|
||||
|
|
|
@ -426,6 +426,16 @@ func (h *handler) CompleteMultipartUploadHandler(w http.ResponseWriter, r *http.
|
|||
}
|
||||
}
|
||||
|
||||
s := &layer.SendNotificationParams{
|
||||
Event: layer.EventObjectCreatedCompleteMultipartUpload,
|
||||
ObjInfo: objInfo,
|
||||
BktInfo: bktInfo,
|
||||
ReqInfo: reqInfo,
|
||||
}
|
||||
if err := h.obj.SendNotifications(r.Context(), s); err != nil {
|
||||
h.log.Error("couldn't send notification: %w", zap.Error(err))
|
||||
}
|
||||
|
||||
if _, err = h.obj.DeleteObjects(r.Context(), bktInfo, []*layer.VersionedObject{{Name: initPart.Name}}); err != nil {
|
||||
h.logAndSendError(w, "could not delete init file of multipart upload", reqInfo, err, additional...)
|
||||
return
|
||||
|
|
|
@ -223,6 +223,16 @@ func (h *handler) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
s := &layer.SendNotificationParams{
|
||||
Event: layer.EventObjectCreatedPut,
|
||||
ObjInfo: info,
|
||||
BktInfo: bktInfo,
|
||||
ReqInfo: reqInfo,
|
||||
}
|
||||
if err := h.obj.SendNotifications(r.Context(), s); err != nil {
|
||||
h.log.Error("couldn't send notification: %w", zap.Error(err))
|
||||
}
|
||||
|
||||
if containsACLHeaders(r) {
|
||||
if newEaclTable, err = h.getNewEAclTable(r, bktInfo, info); err != nil {
|
||||
h.logAndSendError(w, "could not get new eacl table", reqInfo, err)
|
||||
|
@ -320,6 +330,16 @@ func (h *handler) PostObject(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
s := &layer.SendNotificationParams{
|
||||
Event: layer.EventObjectCreatedPost,
|
||||
ObjInfo: info,
|
||||
BktInfo: bktInfo,
|
||||
ReqInfo: reqInfo,
|
||||
}
|
||||
if err := h.obj.SendNotifications(r.Context(), s); err != nil {
|
||||
h.log.Error("couldn't send notification: %w", zap.Error(err))
|
||||
}
|
||||
|
||||
if acl := auth.MultipartFormValue(r, "acl"); acl != "" {
|
||||
r.Header.Set(api.AmzACL, acl)
|
||||
r.Header.Set(api.AmzGrantFullControl, "")
|
||||
|
|
Loading…
Reference in a new issue