From 10094361e04705f3d81a5cbd2f0868467fc9c784 Mon Sep 17 00:00:00 2001 From: liuxiaolong <736321739@qq.com> Date: 星期六, 29 六月 2019 16:37:44 +0800 Subject: [PATCH] rm log --- extend/esutil/EsClient.go | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/extend/esutil/EsClient.go b/extend/esutil/EsClient.go index 79ece4f..6bd550c 100644 --- a/extend/esutil/EsClient.go +++ b/extend/esutil/EsClient.go @@ -98,7 +98,7 @@ return dat, nil } -func PostFormData(uri string, filename, paramName string, file multipart.File) (maps map[string]interface{}, err0 error) { +func PostFormData(uri string, filename, paramName string, fileBytes []byte) (maps map[string]interface{}, err0 error) { body := &bytes.Buffer{} writer := multipart.NewWriter(body) _, err := writer.CreateFormFile(paramName, filename) @@ -106,11 +106,11 @@ return nil, err } boundary := writer.Boundary() - //close_string := fmt.Sprintf("\r\n--%s--\r\n", boundary) close_buf := bytes.NewBufferString(fmt.Sprintf("\r\n--%s--\r\n", boundary)) + fmt.Println("PostFormData.fileLen:",len(fileBytes)) + file := bytes.NewBuffer(fileBytes) request_reader := io.MultiReader(body, file, close_buf) - //_, err = io.Copy(part, file) - //writer.WriteField(key, val) + request, err := http.NewRequest("POST", uri, request_reader) request.Header.Add("Content-Type", writer.FormDataContentType()) timeout := time.Duration(5 * time.Second) //瓒呮椂鏃堕棿50ms -- Gitblit v1.8.0