From bd278337db4e3c1937f2d7cd1623ee9627c77619 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 26 Feb 2013 14:56:18 -0800 Subject: [PATCH] checking file name empty --- go/storage/needle.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/go/storage/needle.go b/go/storage/needle.go index 12d46edff..755b3eafd 100644 --- a/go/storage/needle.go +++ b/go/storage/needle.go @@ -1,13 +1,14 @@ package storage import ( + "code.google.com/p/weed-fs/go/util" "encoding/hex" + "errors" "fmt" "io/ioutil" "mime" "net/http" "path" - "code.google.com/p/weed-fs/go/util" "strconv" "strings" ) @@ -51,7 +52,12 @@ func NewNeedle(r *http.Request) (n *Needle, fname string, e error) { return } fname = part.FileName() - fname = path.Base(fname) + if fname != "" { + fname = path.Base(part.FileName()) + } else { + e = errors.New("No file found!") + return + } data, _ := ioutil.ReadAll(part) dotIndex := strings.LastIndex(fname, ".") ext, mtype := "", ""