From 64b7da4686257dcd893baed7fe9eb32809e0322e Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 3 Feb 2016 00:00:01 -0800 Subject: [PATCH] web: GetObjectURL should check if file exists before generating URL. Fixes - https://github.com/minio/miniobrowser/issues/20 --- server-main.go | 2 +- web-handlers.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server-main.go b/server-main.go index 207856e21..eb7da3598 100644 --- a/server-main.go +++ b/server-main.go @@ -292,7 +292,7 @@ func serverMain(c *cli.Context) { minFreeDisk = 10 args := c.Args() - for len(args) >= 1 { + for len(args) >= 2 { switch args.First() { case "min-free-disk": if minFreeDiskSet { diff --git a/web-handlers.go b/web-handlers.go index 0bb4eb02d..819dbab8d 100644 --- a/web-handlers.go +++ b/web-handlers.go @@ -157,6 +157,13 @@ func (web *WebAPI) GetObjectURL(r *http.Request, args *GetObjectURLArgs, reply * if !isAuthenticated(r) { return errUnAuthorizedRequest } + + // See if object exists. + _, e := web.Client.StatObject(args.BucketName, args.ObjectName) + if e != nil { + return e + } + targetHost, err := getTargetHost(web.apiAddress, args.TargetHost) if err != nil { return probe.WrapError(err)