aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go/operation/submit.go14
-rw-r--r--go/operation/upload_content.go6
-rw-r--r--go/weed/weed_server/volume_server_handlers.go13
3 files changed, 17 insertions, 16 deletions
diff --git a/go/operation/submit.go b/go/operation/submit.go
index 693b90db1..9191f7d9a 100644
--- a/go/operation/submit.go
+++ b/go/operation/submit.go
@@ -25,11 +25,11 @@ type FilePart struct {
}
type SubmitResult struct {
- FileName string `json:"fileName"`
- FileUrl string `json:"fileUrl"`
- Fid string `json:"fid"`
- Size int `json:"size"`
- Error string `json:"error"`
+ FileName string `json:"fileName,omitempty"`
+ FileUrl string `json:"fileUrl,omitempty"`
+ Fid string `json:"fid,omitempty"`
+ Size uint32 `json:"size,omitempty"`
+ Error string `json:"error,omitempty"`
}
func SubmitFiles(master string, files []FilePart, replication string, collection string, maxMB int) ([]SubmitResult, error) {
@@ -99,7 +99,7 @@ func newFilePart(fullPathFilename string) (ret FilePart, err error) {
return ret, nil
}
-func (fi FilePart) Upload(maxMB int, master string) (retSize int, err error) {
+func (fi FilePart) Upload(maxMB int, master string) (retSize uint32, err error) {
fileUrl := "http://" + fi.Server + "/" + fi.Fid
if fi.ModTime != 0 {
fileUrl += "?ts=" + strconv.Itoa(int(fi.ModTime))
@@ -130,7 +130,7 @@ func (fi FilePart) Upload(maxMB int, master string) (retSize int, err error) {
return
}
-func upload_one_chunk(filename string, reader io.Reader, master, replication string, collection string) (fid string, size int, e error) {
+func upload_one_chunk(filename string, reader io.Reader, master, replication string, collection string) (fid string, size uint32, e error) {
ret, err := Assign(master, 1, replication, collection)
if err != nil {
return "", 0, err
diff --git a/go/operation/upload_content.go b/go/operation/upload_content.go
index 646df6886..b89e65ce8 100644
--- a/go/operation/upload_content.go
+++ b/go/operation/upload_content.go
@@ -17,9 +17,9 @@ import (
)
type UploadResult struct {
- Name string
- Size int
- Error string
+ Name string `json:"name,omitempty"`
+ Size uint32 `json:"size,omitempty"`
+ Error string `json:"error,omitempty"`
}
var (
diff --git a/go/weed/weed_server/volume_server_handlers.go b/go/weed/weed_server/volume_server_handlers.go
index 110e00ee1..e2fd6e6f9 100644
--- a/go/weed/weed_server/volume_server_handlers.go
+++ b/go/weed/weed_server/volume_server_handlers.go
@@ -127,7 +127,6 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request,
}
func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
- m := make(map[string]interface{})
if e := r.ParseForm(); e != nil {
glog.V(0).Infoln("form parse error:", e)
writeJsonError(w, r, e)
@@ -145,18 +144,20 @@ func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
writeJsonError(w, r, ne)
return
}
- ret, errorStatus := topology.ReplicatedWrite(vs.masterNode, vs.store, volumeId, needle, r)
+
+ ret := operation.UploadResult{}
+ size, errorStatus := topology.ReplicatedWrite(vs.masterNode, vs.store, volumeId, needle, r)
if errorStatus == "" {
w.WriteHeader(http.StatusCreated)
} else {
w.WriteHeader(http.StatusInternalServerError)
- m["error"] = errorStatus
+ ret.Error = errorStatus
}
if needle.HasName() {
- m["name"] = string(needle.Name)
+ ret.Name = string(needle.Name)
}
- m["size"] = ret
- writeJsonQuiet(w, r, m)
+ ret.Size = size
+ writeJsonQuiet(w, r, ret)
}
func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {