From ff5d486cfe6777799b705b61a1b86d4e4e35ebbc Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Fri, 17 Dec 2021 15:28:18 +0800 Subject: [PATCH] remove upload file --- Makefile | 2 +- conf/ztf.conf | 2 +- src/utils/file/file.go | 4 ++-- src/utils/file/upload.go | 45 ---------------------------------------- src/utils/log/log.go | 4 ++-- src/utils/log/print.go | 6 +++--- 6 files changed, 9 insertions(+), 54 deletions(-) delete mode 100644 src/utils/file/upload.go diff --git a/Makefile b/Makefile index 628b1df8..48c328a5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=2.4 +VERSION=2.5 PROJECT=ztf QINIU_DIR=/Users/aaron/work/zentao/qiniu/ QINIU_DIST_DIR=${QINIU_DIR}${PROJECT}/${VERSION}/ diff --git a/conf/ztf.conf b/conf/ztf.conf index ec6755ae..24029b0c 100644 --- a/conf/ztf.conf +++ b/conf/ztf.conf @@ -1,4 +1,4 @@ -Version = 2.4 +Version = 2.5 Language = zh Url = http://localhost:20080/ Account = admin diff --git a/src/utils/file/file.go b/src/utils/file/file.go index 4e943acb..7db8ee91 100644 --- a/src/utils/file/file.go +++ b/src/utils/file/file.go @@ -3,8 +3,8 @@ package fileUtils import ( "fmt" "github.com/easysoft/zentaoatf/res" - commonUtils "github.com/easysoft/zentaoatf/src/utils/common" - constant "github.com/easysoft/zentaoatf/src/utils/const" + "github.com/easysoft/zentaoatf/src/utils/common" + "github.com/easysoft/zentaoatf/src/utils/const" "github.com/easysoft/zentaoatf/src/utils/vari" "github.com/mholt/archiver/v3" "io" diff --git a/src/utils/file/upload.go b/src/utils/file/upload.go deleted file mode 100644 index 59724647..00000000 --- a/src/utils/file/upload.go +++ /dev/null @@ -1,45 +0,0 @@ -package fileUtils - -import ( - "bytes" - i118Utils "github.com/easysoft/zentaoatf/src/utils/i118" - logUtils "github.com/easysoft/zentaoatf/src/utils/log" - "io" - "io/ioutil" - "mime/multipart" - "net/http" - "os" -) - -func Upload(url string, files []string, extraParams map[string]string) { - bodyBuffer := &bytes.Buffer{} - bodyWriter := multipart.NewWriter(bodyBuffer) - - for _, file := range files { - fw, _ := bodyWriter.CreateFormFile("file", file) - f, _ := os.Open(file) - defer f.Close() - io.Copy(fw, f) - } - - for key, value := range extraParams { - _ = bodyWriter.WriteField(key, value) - } - - contentType := bodyWriter.FormDataContentType() - bodyWriter.Close() - - resp, err := http.Post(url, contentType, bodyBuffer) - defer resp.Body.Close() - - if err != nil { - logUtils.Error(i118Utils.Sprintf("fail_to_upload_file", err.Error())) - } - - respBody, err := ioutil.ReadAll(resp.Body) - if err != nil { - logUtils.Error(i118Utils.Sprintf("fail_to_parse_upload_file_response", err.Error())) - } - - logUtils.Log(i118Utils.Sprintf("upload_file_result", resp.Status, string(respBody))) -} diff --git a/src/utils/log/log.go b/src/utils/log/log.go index 59990ec5..0dfe6510 100644 --- a/src/utils/log/log.go +++ b/src/utils/log/log.go @@ -2,8 +2,8 @@ package logUtils import ( "fmt" - constant "github.com/easysoft/zentaoatf/src/utils/const" - fileUtils "github.com/easysoft/zentaoatf/src/utils/file" + "github.com/easysoft/zentaoatf/src/utils/const" + "github.com/easysoft/zentaoatf/src/utils/file" "github.com/easysoft/zentaoatf/src/utils/i118" "github.com/easysoft/zentaoatf/src/utils/vari" "github.com/fatih/color" diff --git a/src/utils/log/print.go b/src/utils/log/print.go index dfa20826..dd92c6d8 100644 --- a/src/utils/log/print.go +++ b/src/utils/log/print.go @@ -3,9 +3,9 @@ package logUtils import ( "encoding/json" "fmt" - commonUtils "github.com/easysoft/zentaoatf/src/utils/common" - constant "github.com/easysoft/zentaoatf/src/utils/const" - fileUtils "github.com/easysoft/zentaoatf/src/utils/file" + "github.com/easysoft/zentaoatf/src/utils/common" + "github.com/easysoft/zentaoatf/src/utils/const" + "github.com/easysoft/zentaoatf/src/utils/file" "github.com/fatih/color" "os" "regexp" -- GitLab