diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-07-21 15:58:48 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-07-21 15:58:48 -0700 |
| commit | c98df05ed0fc78e8585c6dd7d2ae317c7c42d9c3 (patch) | |
| tree | a198b5fbc61aae585781d229b5bd0c3fd167b23a | |
| parent | feb8eeb83049a24744ca5cbaff78a43835a13636 (diff) | |
| download | seaweedfs-c98df05ed0fc78e8585c6dd7d2ae317c7c42d9c3.tar.xz seaweedfs-c98df05ed0fc78e8585c6dd7d2ae317c7c42d9c3.zip | |
support PUT
| -rw-r--r-- | weed/storage/needle.go | 12 | ||||
| -rw-r--r-- | weed/storage/needle_parse_multipart.go | 7 |
2 files changed, 13 insertions, 6 deletions
diff --git a/weed/storage/needle.go b/weed/storage/needle.go index 7b1b0ba94..46ba933ca 100644 --- a/weed/storage/needle.go +++ b/weed/storage/needle.go @@ -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 } diff --git a/weed/storage/needle_parse_multipart.go b/weed/storage/needle_parse_multipart.go index 0a7c0fc76..112ec32d4 100644 --- a/weed/storage/needle_parse_multipart.go +++ b/weed/storage/needle_parse_multipart.go @@ -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, ".") |
