aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlixianbin <lixianbin@xiaomi.com>2017-01-04 11:23:40 +0800
committerlixianbin <lixianbin@xiaomi.com>2017-01-04 11:23:40 +0800
commitd96d0a87cfb9aa26b83702a72a3affe6d72697b3 (patch)
treeeb5f984e15defc01f5c81072e27a1a1adabf29b2
parentf7ff98c747d2d3a4358fc0de8f0de78706ce9dc7 (diff)
downloadseaweedfs-d96d0a87cfb9aa26b83702a72a3affe6d72697b3.tar.xz
seaweedfs-d96d0a87cfb9aa26b83702a72a3affe6d72697b3.zip
fix bug: upload big .gz file more than maxMB
-rw-r--r--weed/command/upload.go2
-rw-r--r--weed/operation/submit.go11
-rw-r--r--weed/storage/needle.go54
3 files changed, 34 insertions, 33 deletions
diff --git a/weed/command/upload.go b/weed/command/upload.go
index 1f0696f70..d7a468610 100644
--- a/weed/command/upload.go
+++ b/weed/command/upload.go
@@ -63,7 +63,7 @@ var cmdUpload = &Command{
func runUpload(cmd *Command, args []string) bool {
secret := security.Secret(*upload.secretKey)
- if len(cmdUpload.Flag.Args()) == 0 {
+ if len(args) == 0 {
if *upload.dir == "" {
return false
}
diff --git a/weed/operation/submit.go b/weed/operation/submit.go
index 54b6e164e..1de6b544a 100644
--- a/weed/operation/submit.go
+++ b/weed/operation/submit.go
@@ -92,18 +92,15 @@ func newFilePart(fullPathFilename string) (ret FilePart, err error) {
}
ret.Reader = fh
- if fi, fiErr := fh.Stat(); fiErr != nil {
+ fi, fiErr := fh.Stat()
+ if fiErr != nil {
glog.V(0).Info("Failed to stat file:", fullPathFilename)
return ret, fiErr
- } else {
- ret.ModTime = fi.ModTime().UTC().Unix()
- ret.FileSize = fi.Size()
}
+ ret.ModTime = fi.ModTime().UTC().Unix()
+ ret.FileSize = fi.Size()
ext := strings.ToLower(path.Ext(fullPathFilename))
ret.IsGzipped = ext == ".gz"
- if ret.IsGzipped {
- ret.FileName = fullPathFilename[0 : len(fullPathFilename)-3]
- }
ret.FileName = fullPathFilename
if ext != "" {
ret.MimeType = mime.TypeByExtension(ext)
diff --git a/weed/storage/needle.go b/weed/storage/needle.go
index 29549b323..daa050be8 100644
--- a/weed/storage/needle.go
+++ b/weed/storage/needle.go
@@ -106,35 +106,39 @@ func ParseUpload(r *http.Request) (
}
}
- dotIndex := strings.LastIndex(fileName, ".")
- ext, mtype := "", ""
- if dotIndex > 0 {
- ext = strings.ToLower(fileName[dotIndex:])
- mtype = mime.TypeByExtension(ext)
- }
- contentType := part.Header.Get("Content-Type")
- if contentType != "" && mtype != contentType {
- mimeType = contentType //only return mime type if not deductable
- mtype = contentType
- }
- if part.Header.Get("Content-Encoding") == "gzip" {
- isGzipped = true
- } else if operation.IsGzippable(ext, mtype) {
- if data, e = operation.GzipData(data); e != nil {
- return
+ isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
+ isGzipped = false
+ if !isChunkedFile {
+ dotIndex := strings.LastIndex(fileName, ".")
+ ext, mtype := "", ""
+ if dotIndex > 0 {
+ ext = strings.ToLower(fileName[dotIndex:])
+ mtype = mime.TypeByExtension(ext)
+ }
+ contentType := part.Header.Get("Content-Type")
+ if contentType != "" && mtype != contentType {
+ mimeType = contentType //only return mime type if not deductable
+ mtype = contentType
+ }
+ if part.Header.Get("Content-Encoding") == "gzip" {
+ isGzipped = true
+ } else if operation.IsGzippable(ext, mtype) {
+ if data, e = operation.GzipData(data); e != nil {
+ return
+ }
+ isGzipped = true
+ }
+ if ext == ".gz" {
+ isGzipped = true
+ }
+ if strings.HasSuffix(fileName, ".gz") &&
+ !strings.HasSuffix(fileName, ".tar.gz") {
+ fileName = fileName[:len(fileName)-3]
}
- isGzipped = true
- }
- if ext == ".gz" {
- isGzipped = true
- }
- if strings.HasSuffix(fileName, ".gz") &&
- !strings.HasSuffix(fileName, ".tar.gz") {
- fileName = fileName[:len(fileName)-3]
}
modifiedTime, _ = strconv.ParseUint(r.FormValue("ts"), 10, 64)
ttl, _ = ReadTTL(r.FormValue("ttl"))
- isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
+
return
}
func NewNeedle(r *http.Request, fixJpgOrientation bool) (n *Needle, e error) {