|
|
@ -63,7 +63,7 @@ var fileNameEscaper = strings.NewReplacer("\\", "\\\\", "\"", "\\\"") |
|
|
|
|
|
|
|
// Upload sends a POST request to a volume server to upload the content with adjustable compression level
|
|
|
|
func UploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error) { |
|
|
|
uploadResult, err = doUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt) |
|
|
|
uploadResult, err = retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
@ -79,10 +79,22 @@ func doUpload(uploadUrl string, filename string, cipher bool, reader io.Reader, |
|
|
|
err = fmt.Errorf("read input: %v", err) |
|
|
|
return |
|
|
|
} |
|
|
|
uploadResult, uploadErr := doUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt) |
|
|
|
uploadResult, uploadErr := retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt) |
|
|
|
return uploadResult, uploadErr, data |
|
|
|
} |
|
|
|
|
|
|
|
func retriedUploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error) { |
|
|
|
for i:=0; i< 3; i++ { |
|
|
|
uploadResult, err = doUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt) |
|
|
|
if err == nil { |
|
|
|
return |
|
|
|
} else { |
|
|
|
glog.Warningf("uploading to %s: %v", uploadUrl, err) |
|
|
|
} |
|
|
|
} |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error) { |
|
|
|
contentIsGzipped := isInputCompressed |
|
|
|
shouldGzipNow := false |
|
|
|