Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

fix the #59 and #56

yourchangesa86042e413e4
diff --git a/go/storage/needle.go b/go/storage/needle.go
index a24169c000..e4994da3f0 100644
--- a/go/storage/needle.go
+++ b/go/storage/needle.go
@@ -59,19 +59,13 @@ func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string
e = fe
return
}
- part, fe := form.NextPart()
- for {
- if fe != nil {
- glog.V(0).Infoln("Reading Multi part [ERROR]", fe)
- e = fe
- return
- }
- if part.FileName() != "" {
- break //found the first <file type> multi-part
- }
-
- part, fe = form.NextPart()
+ //first multi-part item
+ part, fe := form.NextPart()
+ if fe != nil {
+ glog.V(0).Infoln("Reading Multi part [ERROR]", fe)
+ e = fe
+ return
}
fileName = part.FileName()
@@ -84,6 +78,32 @@ func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string
glog.V(0).Infoln("Reading Content [ERROR]", e)
return
}
+
+ //if the filename is empty string, do a search on the other multi-part items
+ for fileName == "" {
+ part2, fe := form.NextPart()
+ if fe != nil {
+ break // no more or on error, just safely break
+ }
+
+ fName := part2.FileName()
+
+ //found the first <file type> multi-part has filename
+ if fName != "" {
+ data2, fe2 := ioutil.ReadAll(part2)
+ if fe2 != nil {
+ glog.V(0).Infoln("Reading Content [ERROR]", fe2)
+ e = fe2
+ return
+ }
+
+ //update
+ data = data2
+ fileName = path.Base(fName)
+ break
+ }
+ }
+
dotIndex := strings.LastIndex(fileName, ".")
ext, mtype := "", ""
if dotIndex > 0 {