mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
byte buffer for uploading
This commit is contained in:
parent
2579edbc60
commit
29c9fa2ef2
|
@ -188,8 +188,9 @@ 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) {
|
||||||
body_buf := bytes.NewBufferString("")
|
buf := bytebufferpool.Get()
|
||||||
body_writer := multipart.NewWriter(body_buf)
|
defer bytebufferpool.Put(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 == "" {
|
||||||
|
@ -217,7 +218,7 @@ func upload_content(uploadUrl string, fillBufferFunction func(w io.Writer) error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req, postErr := http.NewRequest("POST", uploadUrl, body_buf)
|
req, postErr := http.NewRequest("POST", uploadUrl, bytes.NewReader(buf.Bytes()))
|
||||||
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