mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
avoid reparsing the multipart form
This commit is contained in:
parent
e4b7e31902
commit
4d322df95e
|
@ -29,12 +29,12 @@ type Needle struct {
|
|||
|
||||
DataSize uint32 `comment:"Data size"` //version2
|
||||
Data []byte `comment:"The actual file data"`
|
||||
Flags byte `comment:"boolean flags"` //version2
|
||||
NameSize uint8 //version2
|
||||
Flags byte `comment:"boolean flags"` //version2
|
||||
NameSize uint8 //version2
|
||||
Name []byte `comment:"maximum 256 characters"` //version2
|
||||
MimeSize uint8 //version2
|
||||
MimeSize uint8 //version2
|
||||
Mime []byte `comment:"maximum 256 characters"` //version2
|
||||
PairsSize uint16 //version2
|
||||
PairsSize uint16 //version2
|
||||
Pairs []byte `comment:"additional name value pairs, json format, maximum 64kB"`
|
||||
LastModified uint64 //only store LastModifiedBytesLength bytes, which is 5 bytes to disk
|
||||
Ttl *TTL
|
||||
|
@ -59,10 +59,8 @@ func ParseUpload(r *http.Request) (
|
|||
}
|
||||
}
|
||||
|
||||
isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
|
||||
|
||||
if r.Method == "POST" {
|
||||
fileName, data, mimeType, isGzipped, e = parseMultipart(r, isChunkedFile)
|
||||
fileName, data, mimeType, isGzipped, isChunkedFile, e = parseMultipart(r)
|
||||
} else {
|
||||
isGzipped = false
|
||||
mimeType = r.Header.Get("Content-Type")
|
||||
|
|
|
@ -8,10 +8,11 @@ import (
|
|||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func parseMultipart(r *http.Request, isChunkedFile bool) (
|
||||
fileName string, data []byte, mimeType string, isGzipped bool, e error) {
|
||||
func parseMultipart(r *http.Request) (
|
||||
fileName string, data []byte, mimeType string, isGzipped, isChunkedFile bool, e error) {
|
||||
form, fe := r.MultipartReader()
|
||||
if fe != nil {
|
||||
glog.V(0).Infoln("MultipartReader [ERROR]", fe)
|
||||
|
@ -63,6 +64,8 @@ func parseMultipart(r *http.Request, isChunkedFile bool) (
|
|||
}
|
||||
}
|
||||
|
||||
isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
|
||||
|
||||
if !isChunkedFile {
|
||||
|
||||
dotIndex := strings.LastIndex(fileName, ".")
|
||||
|
|
Loading…
Reference in a new issue