aboutsummaryrefslogtreecommitdiff
path: root/weed/operation
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-09-22 22:12:21 -0700
committerChris Lu <chris.lu@gmail.com>2018-09-22 22:12:21 -0700
commit7d6b2a4740c32c3a07a4ce4204da2debee371bcd (patch)
treed60d69c2ed0deea37a63afeabae516551cb090c8 /weed/operation
parent420f0683764ce97080ad6fb7dec4df3aa75480bc (diff)
downloadseaweedfs-7d6b2a4740c32c3a07a4ce4204da2debee371bcd.tar.xz
seaweedfs-7d6b2a4740c32c3a07a4ce4204da2debee371bcd.zip
add ETag to upload results and chunks
Diffstat (limited to 'weed/operation')
-rw-r--r--weed/operation/upload_content.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go
index 30c7f1ea3..1fd0ed2b9 100644
--- a/weed/operation/upload_content.go
+++ b/weed/operation/upload_content.go
@@ -22,6 +22,7 @@ type UploadResult struct {
Name string `json:"name,omitempty"`
Size uint32 `json:"size,omitempty"`
Error string `json:"error,omitempty"`
+ ETag string `json:"error,omitempty"`
}
var (
@@ -90,6 +91,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
return nil, post_err
}
defer resp.Body.Close()
+ etag := getEtag(resp)
resp_body, ra_err := ioutil.ReadAll(resp.Body)
if ra_err != nil {
return nil, ra_err
@@ -103,5 +105,14 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
if ret.Error != "" {
return nil, errors.New(ret.Error)
}
+ ret.ETag = etag
return &ret, nil
}
+
+func getEtag(r *http.Response) (etag string) {
+ etag = r.Header.Get("ETag")
+ if strings.HasPrefix(etag, "\"") && strings.HasSuffix(etag, "\"") {
+ etag = etag[1 : len(etag)-1]
+ }
+ return
+}