提交 ff5d486c 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

remove upload file

上级 3577b5c4
VERSION=2.4
VERSION=2.5
PROJECT=ztf
QINIU_DIR=/Users/aaron/work/zentao/qiniu/
QINIU_DIST_DIR=${QINIU_DIR}${PROJECT}/${VERSION}/
......
Version = 2.4
Version = 2.5
Language = zh
Url = http://localhost:20080/
Account = admin
......
......@@ -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"
......
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)))
}
......@@ -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"
......
......@@ -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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册