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.

checking file name empty

Chris Lubd278337db4e
diff --git a/go/storage/needle.go b/go/storage/needle.go
index 12d46edff9..755b3eafda 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 := "", ""