add log messages
This commit is contained in:
@@ -3,7 +3,6 @@ package operation
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -210,8 +209,8 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
|||||||
|
|
||||||
req, postErr := http.NewRequest("POST", uploadUrl, body_buf)
|
req, postErr := http.NewRequest("POST", uploadUrl, body_buf)
|
||||||
if postErr != nil {
|
if postErr != nil {
|
||||||
glog.V(1).Infof("failing to upload to %s: %v", uploadUrl, postErr)
|
glog.V(1).Infof("create upload request %s: %v", uploadUrl, postErr)
|
||||||
return nil, fmt.Errorf("failing to upload to %s: %v", uploadUrl, postErr)
|
return nil, fmt.Errorf("create upload request %s: %v", uploadUrl, postErr)
|
||||||
}
|
}
|
||||||
req.Header.Set("Content-Type", content_type)
|
req.Header.Set("Content-Type", content_type)
|
||||||
for k, v := range pairMap {
|
for k, v := range pairMap {
|
||||||
@@ -222,8 +221,8 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
|||||||
}
|
}
|
||||||
resp, post_err := HttpClient.Do(req)
|
resp, post_err := HttpClient.Do(req)
|
||||||
if post_err != nil {
|
if post_err != nil {
|
||||||
glog.V(1).Infof("failing to upload to %v: %v", uploadUrl, post_err)
|
glog.Errorf("upload to %v: %v", uploadUrl, post_err)
|
||||||
return nil, fmt.Errorf("failing to upload to %v: %v", uploadUrl, post_err)
|
return nil, fmt.Errorf("upload to %v: %v", uploadUrl, post_err)
|
||||||
}
|
}
|
||||||
defer util.CloseResponse(resp)
|
defer util.CloseResponse(resp)
|
||||||
|
|
||||||
@@ -236,16 +235,16 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
|||||||
|
|
||||||
resp_body, ra_err := ioutil.ReadAll(resp.Body)
|
resp_body, ra_err := ioutil.ReadAll(resp.Body)
|
||||||
if ra_err != nil {
|
if ra_err != nil {
|
||||||
return nil, ra_err
|
return nil, fmt.Errorf("read response body %v: %v", uploadUrl, ra_err)
|
||||||
}
|
}
|
||||||
|
|
||||||
unmarshal_err := json.Unmarshal(resp_body, &ret)
|
unmarshal_err := json.Unmarshal(resp_body, &ret)
|
||||||
if unmarshal_err != nil {
|
if unmarshal_err != nil {
|
||||||
glog.V(0).Infoln("failing to read upload response", uploadUrl, string(resp_body))
|
glog.Errorf("unmarshal %s: %v", uploadUrl, string(resp_body))
|
||||||
return nil, unmarshal_err
|
return nil, fmt.Errorf("unmarshal %v: %v", uploadUrl, unmarshal_err)
|
||||||
}
|
}
|
||||||
if ret.Error != "" {
|
if ret.Error != "" {
|
||||||
return nil, errors.New(ret.Error)
|
return nil, fmt.Errorf("unmarshalled error %v: %v", uploadUrl, ret.Error)
|
||||||
}
|
}
|
||||||
ret.ETag = etag
|
ret.ETag = etag
|
||||||
ret.ContentMd5 = resp.Header.Get("Content-MD5")
|
ret.ContentMd5 = resp.Header.Get("Content-MD5")
|
||||||
|
|||||||
Reference in New Issue
Block a user