diff options
| author | Chris Lu <chris.lu@gmail.com> | 2020-10-20 23:48:29 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2020-10-20 23:48:29 -0700 |
| commit | c31b2542489ea4cddffbf1efedbdb867fb6cdb2f (patch) | |
| tree | 9762a4b1c79c6c27b83bfef3c3b285aa7a613c65 /weed/operation/upload_content.go | |
| parent | f64252023ee882264ea1b220afbdf0321e26a56b (diff) | |
| download | seaweedfs-c31b2542489ea4cddffbf1efedbdb867fb6cdb2f.tar.xz seaweedfs-c31b2542489ea4cddffbf1efedbdb867fb6cdb2f.zip | |
mount: shortcut when there is only one chunk
Diffstat (limited to 'weed/operation/upload_content.go')
| -rw-r--r-- | weed/operation/upload_content.go | 13 |
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 |
