mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
support PUT
This commit is contained in:
parent
feb8eeb830
commit
c98df05ed0
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/chrislusf/seaweedfs/weed/images"
|
||||
. "github.com/chrislusf/seaweedfs/weed/storage/types"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -57,7 +58,16 @@ func ParseUpload(r *http.Request) (
|
|||
}
|
||||
}
|
||||
|
||||
fileName, data, mimeType, isGzipped, isChunkedFile, e = parseMultipart(r)
|
||||
isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
|
||||
|
||||
if r.Method == "POST" {
|
||||
fileName, data, mimeType, isGzipped, e = parseMultipart(r, isChunkedFile)
|
||||
} else {
|
||||
isGzipped = false
|
||||
mimeType = r.Header.Get("Content-Type")
|
||||
fileName = ""
|
||||
data, e = ioutil.ReadAll(r.Body)
|
||||
}
|
||||
if e != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -8,11 +8,10 @@ import (
|
|||
"path"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func parseMultipart(r *http.Request) (
|
||||
fileName string, data []byte, mimeType string, isGzipped bool, isChunkedFile bool, e error){
|
||||
func parseMultipart(r *http.Request, isChunkedFile bool) (
|
||||
fileName string, data []byte, mimeType string, isGzipped bool, e error) {
|
||||
form, fe := r.MultipartReader()
|
||||
if fe != nil {
|
||||
glog.V(0).Infoln("MultipartReader [ERROR]", fe)
|
||||
|
@ -64,8 +63,6 @@ func parseMultipart(r *http.Request) (
|
|||
}
|
||||
}
|
||||
|
||||
isChunkedFile, _ = strconv.ParseBool(r.FormValue("cm"))
|
||||
|
||||
if !isChunkedFile {
|
||||
|
||||
dotIndex := strings.LastIndex(fileName, ".")
|
||||
|
|
Loading…
Reference in a new issue