From 7481b7376d0349938a99b08e5dfab0b2009b2e89 Mon Sep 17 00:00:00 2001 From: yourchanges Date: Sat, 10 Jan 2015 03:22:16 +0800 Subject: [PATCH] Fix the first form multi-part item is not a "file type part" problem in "ParseUpload()" --- go/storage/needle.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/go/storage/needle.go b/go/storage/needle.go index 11610dd80..a24169c00 100644 --- a/go/storage/needle.go +++ b/go/storage/needle.go @@ -60,11 +60,20 @@ func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string return } part, fe := form.NextPart() - if fe != nil { - glog.V(0).Infoln("Reading Multi part [ERROR]", fe) - e = fe - return + for { + if fe != nil { + glog.V(0).Infoln("Reading Multi part [ERROR]", fe) + e = fe + return + } + + if part.FileName() != "" { + break //found the first multi-part + } + + part, fe = form.NextPart() } + fileName = part.FileName() if fileName != "" { fileName = path.Base(fileName)