Browse Source

Merge pull request #428 from sparklxb/master

fix bug: upload big .gz file more than maxMB
pull/430/head
Chris Lu 8 years ago
committed by GitHub
parent
commit
297f64e286
  1. 2
      weed/command/upload.go
  2. 9
      weed/operation/submit.go
  3. 6
      weed/storage/needle.go

2
weed/command/upload.go

@ -63,7 +63,7 @@ var cmdUpload = &Command{
func runUpload(cmd *Command, args []string) bool { func runUpload(cmd *Command, args []string) bool {
secret := security.Secret(*upload.secretKey) secret := security.Secret(*upload.secretKey)
if len(cmdUpload.Flag.Args()) == 0 {
if len(args) == 0 {
if *upload.dir == "" { if *upload.dir == "" {
return false return false
} }

9
weed/operation/submit.go

@ -92,18 +92,15 @@ func newFilePart(fullPathFilename string) (ret FilePart, err error) {
} }
ret.Reader = fh 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) glog.V(0).Info("Failed to stat file:", fullPathFilename)
return ret, fiErr return ret, fiErr
} else {
}
ret.ModTime = fi.ModTime().UTC().Unix() ret.ModTime = fi.ModTime().UTC().Unix()
ret.FileSize = fi.Size() ret.FileSize = fi.Size()
}
ext := strings.ToLower(path.Ext(fullPathFilename)) ext := strings.ToLower(path.Ext(fullPathFilename))
ret.IsGzipped = ext == ".gz" ret.IsGzipped = ext == ".gz"
if ret.IsGzipped {
ret.FileName = fullPathFilename[0 : len(fullPathFilename)-3]
}
ret.FileName = fullPathFilename ret.FileName = fullPathFilename
if ext != "" { if ext != "" {
ret.MimeType = mime.TypeByExtension(ext) ret.MimeType = mime.TypeByExtension(ext)

6
weed/storage/needle.go

@ -106,6 +106,9 @@ func ParseUpload(r *http.Request) (
} }
} }
isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
isGzipped = false
if !isChunkedFile {
dotIndex := strings.LastIndex(fileName, ".") dotIndex := strings.LastIndex(fileName, ".")
ext, mtype := "", "" ext, mtype := "", ""
if dotIndex > 0 { if dotIndex > 0 {
@ -132,9 +135,10 @@ func ParseUpload(r *http.Request) (
!strings.HasSuffix(fileName, ".tar.gz") { !strings.HasSuffix(fileName, ".tar.gz") {
fileName = fileName[:len(fileName)-3] fileName = fileName[:len(fileName)-3]
} }
}
modifiedTime, _ = strconv.ParseUint(r.FormValue("ts"), 10, 64) modifiedTime, _ = strconv.ParseUint(r.FormValue("ts"), 10, 64)
ttl, _ = ReadTTL(r.FormValue("ttl")) ttl, _ = ReadTTL(r.FormValue("ttl"))
isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
return return
} }
func NewNeedle(r *http.Request, fixJpgOrientation bool) (n *Needle, e error) { func NewNeedle(r *http.Request, fixJpgOrientation bool) (n *Needle, e error) {

Loading…
Cancel
Save