From 3a8fff46f96e62e309206bb8dc04c8b2871100b9 Mon Sep 17 00:00:00 2001 From: Krishna Srinivas Date: Fri, 5 Feb 2016 19:46:36 +0530 Subject: [PATCH] JSONrpc: implement removeObject RPC call --- web-definitions.go | 7 +++++++ web-handlers.go | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/web-definitions.go b/web-definitions.go index ff245e6b7..44de8ecb0 100644 --- a/web-definitions.go +++ b/web-definitions.go @@ -52,6 +52,13 @@ type GetObjectURLArgs struct { ObjectName string `json:"objectName"` } +// RemoveObjectArgs - args to remove an object +type RemoveObjectArgs struct { + TargetHost string `json:"targetHost"` + BucketName string `json:"bucketName"` + ObjectName string `json:"objectName"` +} + // BucketInfo container for list buckets metadata. type BucketInfo struct { // The name of the bucket. diff --git a/web-handlers.go b/web-handlers.go index eedd90387..169bedd7b 100644 --- a/web-handlers.go +++ b/web-handlers.go @@ -214,6 +214,20 @@ func (web *WebAPI) GetObjectURL(r *http.Request, args *GetObjectURLArgs, reply * return nil } +// RemoveObject - removes an object. +func (web *WebAPI) RemoveObject(r *http.Request, args *RemoveObjectArgs, reply *int) error { + if !isAuthenticated(r) { + return errUnAuthorizedRequest + } + + e := web.Client.RemoveObject(args.BucketName, args.ObjectName) + if e != nil { + return e + } + *reply = 0 + return nil +} + // Login - user login handler. func (web *WebAPI) Login(r *http.Request, args *LoginArgs, reply *AuthToken) error { jwt := InitJWT()