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/pb/filer_pb"
|
||||||
"github.com/chrislusf/seaweedfs/weed/security"
|
"github.com/chrislusf/seaweedfs/weed/security"
|
||||||
"github.com/chrislusf/seaweedfs/weed/util"
|
"github.com/chrislusf/seaweedfs/weed/util"
|
||||||
"github.com/valyala/bytebufferpool"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UploadResult struct {
|
type UploadResult struct {
|
||||||
|
@ -81,14 +80,11 @@ func doUpload(uploadUrl string, filename string, cipher bool, reader io.Reader,
|
||||||
if ok {
|
if ok {
|
||||||
data = bytesReader.Bytes
|
data = bytesReader.Bytes
|
||||||
} else {
|
} else {
|
||||||
buf := bytebufferpool.Get()
|
data, err = ioutil.ReadAll(reader)
|
||||||
_, err = buf.ReadFrom(reader)
|
|
||||||
defer bytebufferpool.Put(buf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("read input: %v", err)
|
err = fmt.Errorf("read input: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
data = buf.Bytes()
|
|
||||||
}
|
}
|
||||||
uploadResult, uploadErr := retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
|
uploadResult, uploadErr := retriedUploadData(uploadUrl, filename, cipher, data, isInputCompressed, mtype, pairMap, jwt)
|
||||||
return uploadResult, uploadErr, data
|
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) {
|
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()
|
body_buf := bytes.NewBufferString("")
|
||||||
defer bytebufferpool.Put(buf)
|
body_writer := multipart.NewWriter(body_buf)
|
||||||
body_writer := multipart.NewWriter(buf)
|
|
||||||
h := make(textproto.MIMEHeader)
|
h := make(textproto.MIMEHeader)
|
||||||
h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, fileNameEscaper.Replace(filename)))
|
h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="file"; filename="%s"`, fileNameEscaper.Replace(filename)))
|
||||||
if mtype == "" {
|
if mtype == "" {
|
||||||
|
@ -218,7 +213,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, postErr := http.NewRequest("POST", uploadUrl, bytes.NewReader(buf.Bytes()))
|
req, postErr := http.NewRequest("POST", uploadUrl, body_buf)
|
||||||
if postErr != nil {
|
if postErr != nil {
|
||||||
glog.V(1).Infof("create upload request %s: %v", uploadUrl, postErr)
|
glog.V(1).Infof("create upload request %s: %v", uploadUrl, postErr)
|
||||||
return nil, fmt.Errorf("create upload request %s: %v", uploadUrl, postErr)
|
return nil, fmt.Errorf("create upload request %s: %v", uploadUrl, postErr)
|
||||||
|
|
Loading…
Reference in a new issue