mirror of
https://github.com/pgsty/minio.git
synced 2026-08-10 16:23:28 +03:00
browser: Object upload should save metadata and notify. (#2309)
Object upload from browser should save additional incoming metadata. Additionally should also notify through bucket notifications once they are set. Fixes #2292
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
ad19bf0ec1
commit
65f71ce0c5
+28
-2
@@ -374,10 +374,36 @@ func (web *webAPIHandlers) Upload(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
bucket := vars["bucket"]
|
||||
object := vars["object"]
|
||||
// FIXME: Allow file upload handler to set content-type, content-encoding.
|
||||
if _, err := web.ObjectAPI.PutObject(bucket, object, -1, r.Body, nil); err != nil {
|
||||
|
||||
// Extract incoming metadata if any.
|
||||
metadata := extractMetadataFromHeader(r.Header)
|
||||
|
||||
if _, err := web.ObjectAPI.PutObject(bucket, object, -1, r.Body, metadata); err != nil {
|
||||
writeWebErrorResponse(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Load notification config if any.
|
||||
nConfig, err := loadNotificationConfig(web.ObjectAPI, bucket)
|
||||
// Notifications not set, return.
|
||||
if err == errNoSuchNotifications {
|
||||
return
|
||||
}
|
||||
// For all other errors, return.
|
||||
if err != nil {
|
||||
errorIf(err, "Unable to load notification config for bucket: \"%s\"", bucket)
|
||||
return
|
||||
}
|
||||
|
||||
// Fetch object info for notifications.
|
||||
objInfo, err := web.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.
|
||||
notifyObjectCreatedEvent(nConfig, ObjectCreatedPut, bucket, objInfo)
|
||||
}
|
||||
|
||||
// Download - file download handler.
|
||||
|
||||
Reference in New Issue
Block a user