aboutsummaryrefslogtreecommitdiff
path: root/weed/operation
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-10-20 23:48:29 -0700
committerChris Lu <chris.lu@gmail.com>2020-10-20 23:48:29 -0700
commitc31b2542489ea4cddffbf1efedbdb867fb6cdb2f (patch)
tree9762a4b1c79c6c27b83bfef3c3b285aa7a613c65 /weed/operation
parentf64252023ee882264ea1b220afbdf0321e26a56b (diff)
downloadseaweedfs-c31b2542489ea4cddffbf1efedbdb867fb6cdb2f.tar.xz
seaweedfs-c31b2542489ea4cddffbf1efedbdb867fb6cdb2f.zip
mount: shortcut when there is only one chunk
Diffstat (limited to 'weed/operation')
-rw-r--r--weed/operation/upload_content.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/weed/operation/upload_content.go b/weed/operation/upload_content.go
index e9002d09d..9eb05f6e1 100644
--- a/weed/operation/upload_content.go
+++ b/weed/operation/upload_content.go
@@ -76,10 +76,15 @@ func Upload(uploadUrl string, filename string, cipher bool, reader io.Reader, is
}
func doUpload(uploadUrl string, filename string, cipher bool, reader io.Reader, isInputCompressed bool, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (uploadResult *UploadResult, err error, data []byte) {
- data, err = ioutil.ReadAll(reader)
- if err != nil {
- err = fmt.Errorf("read input: %v", err)
- return
+ bytesReader, ok := reader.(*util.BytesReader)
+ if ok {
+ data = bytesReader.Bytes
+ } else {
+ data, err = ioutil.ReadAll(reader)
+ if err != nil {
+ err = fmt.Errorf("read input: %v", err)
+ return
+ }
}
uploadResult, uploadErr := retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
return uploadResult, uploadErr, data