mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
revert bytebufferpool, seems problematic
This commit is contained in:
parent
e1423a83dd
commit
e0fcab47c0
|
@ -19,7 +19,6 @@ import (
|
|||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/security"
|
||||
"github.com/chrislusf/seaweedfs/weed/util"
|
||||
"github.com/valyala/bytebufferpool"
|
||||
)
|
||||
|
||||
type UploadResult struct {
|
||||
|
@ -81,14 +80,11 @@ func doUpload(uploadUrl string, filename string, cipher bool, reader io.Reader,
|
|||
if ok {
|
||||
data = bytesReader.Bytes
|
||||
} else {
|
||||
buf := bytebufferpool.Get()
|
||||
_, err = buf.ReadFrom(reader)
|
||||
defer bytebufferpool.Put(buf)
|
||||
data, err = ioutil.ReadAll(reader)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("read input: %v", err)
|
||||
return
|
||||
}
|
||||
data = buf.Bytes()
|
||||
}
|
||||
uploadResult, uploadErr := retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
|
||||
return uploadResult, uploadErr, data
|
||||
|
@ -188,9 +184,8 @@ func doUploadData(uploadUrl string, filename string, cipher bool, data []byte, i
|
|||
}
|
||||
|
||||
func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error, filename string, isGzipped bool, originalDataSize int, mtype string, pairMap map[string]string, jwt security.EncodedJwt) (*UploadResult, error) {
|
||||
buf := bytebufferpool.Get()
|
||||
defer bytebufferpool.Put(buf)
|
||||
body_writer := multipart.NewWriter(buf)
|
||||
body_buf := bytes.NewBufferString("")
|
||||
body_writer := multipart.NewWriter(body_buf)
|
||||
h := make(textproto.MIMEHeader)
|
||||
h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, fileNameEscaper.Replace(filename)))
|
||||
if mtype == "" {
|
||||
|
@ -218,7 +213,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
req, postErr := http.NewRequest("POST", uploadUrl, bytes.NewReader(buf.Bytes()))
|
||||
req, postErr := http.NewRequest("POST", uploadUrl, body_buf)
|
||||
if postErr != nil {
|
||||
glog.V(1).Infof("create upload request %s: %v", uploadUrl, postErr)
|
||||
return nil, fmt.Errorf("create upload request %s: %v", uploadUrl, postErr)
|
||||
|
|
Loading…
Reference in a new issue