Browse Source

远程上传完成

qin_1
超级管理员 4 years ago
parent
commit
1b86c4e158
  1. 127
      gin_server_admin/api/v1/fileuploaddownload/fileupdowntype.go
  2. 297
      gin_server_admin/api/v1/fileuploaddownload/fileuploaddown.go
  3. 157
      gin_server_admin/api/v1/fileuploaddownload/jhk.go
  4. 5
      gin_server_admin/commonus/jsonStruct.go
  5. 4
      gin_server_admin/commonus/mapOutput.go
  6. 49
      gin_server_admin/commonus/md5Sub.go
  7. 6
      gin_server_admin/config.yaml
  8. 2
      gin_server_admin/config/config.go
  9. 6
      gin_server_admin/config/privateConfig.go
  10. 3
      gin_server_admin/global/global.go
  11. 2
      gin_server_admin/main.go
  12. BIN
      gin_server_admin/uploads/12221.png
  13. BIN
      gin_server_admin/uploads/2503.jpg
  14. BIN
      gin_server_admin/uploads/365.jpg
  15. BIN
      gin_server_admin/uploads/file/21deede44c2794d58ccf11ee2de528cd_20211225113512.jpg
  16. BIN
      gin_server_admin/uploads/file/310dcbbf4cce62f762a2aaa148d556bd_20211222135245.jpg
  17. BIN
      gin_server_admin/uploads/file/434d8300ae1b16ca8d70d151289c8376_20211225130904.png
  18. BIN
      gin_server_admin/uploads/file/56729ce2ce6625d5a10259e2532123e8_20211222132603.jpg
  19. BIN
      gin_server_admin/uploads/file/6c9882bbac1c7093bd25041881277658_20211222132541.png
  20. BIN
      gin_server_admin/uploads/file/6c9882bbac1c7093bd25041881277658_20211222135154.png
  21. BIN
      gin_server_admin/uploads/file/6c9882bbac1c7093bd25041881277658_20211225130849.png
  22. BIN
      gin_server_admin/uploads/file/7884a9652e94555c70f96b6be63be216_20211225132701.png
  23. 2
      web/src/view/example/upload/upload.vue

127
gin_server_admin/api/v1/fileuploaddownload/fileupdowntype.go

@ -0,0 +1,127 @@
package fileuploaddownload
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"strconv"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
"github.com/flipped-aurora/gin-vue-admin/server/global"
)
//上传文件返回前端
type UpLoadFileStruct struct {
ID int64 `json:"ID"`
Key string `json:"key"`
Name string `json:"name"`
Tag string `json:"tag"`
Url string `json:"url"`
PhysicsPath string `json:"physicspath"`
CreatedAt time.Time `json:"CreatedAt"`
UpdatedAt time.Time `json:"UpdatedAt"`
FileSize int64 `json:"fileSize"` //大小
}
//文件基本属性
type FileAttribute struct {
FileName string `json:"fileName"`
FileSize int64 `json:"fileSize"`
FileExt string `json:"fileExt"`
}
//远程数据返回
type CallBackFileData struct {
commonus.ReturnJson
Data RemoteUploadDataStruct `json:data`
}
//远程上传返回
type RemoteUploadDataStruct struct {
Callbackurl string `json:"callbackurl"` //预览地址
FilePath string `json:"filePath"` //物理地址
Ext string `json:"ext"` //文件后缀
Names string `json:"names"` //文件新名称
NewName string `json:"newName"` //文件原名称
GetSize int64 `json:"getSize"` //文件大小
GetOriginalMime string `json:"getOriginalMime"` //上传方式
Physicspath string `json:"physicspath"` //相对路径
}
//上传到远程服务器
func postFormDataWithSingleFile(filePath string, fileType int) (CallBackFileData CallBackFileData) {
client := http.Client{}
bodyBuf := &bytes.Buffer{}
bodyWrite := multipart.NewWriter(bodyBuf)
file, err := os.Open(filePath)
defer file.Close()
if err != nil {
CallBackFileData.Code = 100
CallBackFileData.Msg = "打开文件失败!"
return
}
var upFileMd5 commonus.Md5Encryption
jsonSend := commonus.MapOut()
jsonSend["type"] = fileType
mapJson, _ := json.Marshal(jsonSend)
upFileMd5.Code = string(mapJson)
upSign := upFileMd5.Md5EncryptionAlgorithm()
// fmt.Println(upSign)
// return
bodyWrite.WriteField("type", strconv.Itoa(fileType))
bodyWrite.WriteField("sign", upSign)
// file 为key
fileWrite, err := bodyWrite.CreateFormFile("file", filePath)
_, err = io.Copy(fileWrite, file)
if err != nil {
CallBackFileData.Code = 101
CallBackFileData.Msg = "创建文件发送包失败!"
return
}
bodyWrite.Close() //要关闭,会将w.w.boundary刷写到w.writer中
// 创建请求
contentType := bodyWrite.FormDataContentType()
req, err := http.NewRequest(http.MethodPost, global.GVA_CONFIG.MyConfig.Visit, bodyBuf)
if err != nil {
CallBackFileData.Code = 102
CallBackFileData.Msg = "远程上传失败!"
return
}
// 设置头
req.Header.Set("Content-Type", contentType)
resp, err := client.Do(req)
if err != nil {
CallBackFileData.Code = 103
CallBackFileData.Msg = "读取返回文件失败"
return
}
defer resp.Body.Close()
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
CallBackFileData.Code = 104
CallBackFileData.Msg = "解析返回文件失败"
return
}
// var CallBackFileData CallBackFileData
jsonErr := json.Unmarshal(b, &CallBackFileData)
fmt.Println(string(b))
// fmt.Println(CallBackFileData)
if jsonErr != nil {
CallBackFileData.Code = 105
// CallBackFileData.Msg = "解析返回数据失败!"
return
}
if CallBackFileData.Code != 1 {
return
}
// fmt.Println(string(b))
return
}

297
gin_server_admin/api/v1/fileuploaddownload/fileuploaddown.go

@ -1,15 +1,9 @@
package fileuploaddownload
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"unsafe"
"os"
"path"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
@ -25,264 +19,61 @@ type urlData struct {
//上传文件(远程)
func (f *FileUploadDownload) LongRangeFileUpload(c *gin.Context) {
// var file example.ExaFileUploadAndDownload
// noSave := c.DefaultQuery("noSave", "0")
var reportStatistics urlData
err := c.ShouldBindJSON(&reportStatistics)
var urlData urlData
// c.ShouldBindJSON(&urlData)
file, errs := c.FormFile("file")
// filePart, header, err := c.Request.FormFile("file")
outPut := commonus.MapOut()
// outPut["filePart"] = filePart
// outPut["header"] = header
// outPut["err"] = err
// outPut["noSave"] = noSave
outPut["file"] = file
outPut["errs"] = errs
outPut["err"] = err
outPut["reportStatistics"] = reportStatistics
// url := "http://docu.hxgk.net/uploadfileing/uploadimging"
var jsonPostSample JsonPostSample
jsonPostSample.SamplePost()
// client := &http.Client{}
// config := map[string]interface{}{}
// config["type"] = 0
// config["sign"] = "input"
// // config["afa"] = 2
// configdata, _ := json.Marshal(config)
// outPut["configdata"] = string(configdata)
// //json序列化
// post := "{\"type\":\"" + string(configdata) +
// "\",\"sign\":\"" + string(configdata) +
// "\"}"
// fmt.Println(url, "post", post)
// var jsonStr = []byte(post)
// fmt.Println("jsonStr", jsonStr)
// fmt.Println("new_str", bytes.NewBuffer(jsonStr))
// // req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
// posts := "type=1&sign=123"
// req, err := http.NewRequest("POST", url, strings.NewReader(posts))
// if err != nil {
// // handle error
// }
// req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// // req.Header.Set("Content-Type", "application/json")
// // req.Header.Set("Cookie", "name=anny")
// resp, err := client.Do(req)
// defer resp.Body.Close()
// body, err := ioutil.ReadAll(resp.Body)
// outPut["body"] = string(body)
response.Result(0, outPut, "获取成功", c)
}
func sendPost1(urlStr string) {
data := make(url.Values)
data["name"] = []string{"rnben"}
res, err := http.PostForm(urlStr, data)
if err != nil {
fmt.Println(err.Error())
return
if urlData.Type == 0 {
urlData.Type = 5
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Printf("==============>%v\n", string(body))
}
func postData(urlStr string) {
http.HandleFunc(urlStr, func(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" {
var (
name string = r.PostFormValue("type")
)
fmt.Printf("key is : %s\n", name)
}
})
_, fileHeader, fileErr := c.Request.FormFile("file")
err := http.ListenAndServe(":80", nil)
if err != nil {
fmt.Println(err.Error())
if fileErr != nil {
response.Result(101, fileHeader, "获取文件错误!", c)
return
}
}
func httpDo(urlStr string) {
client := &http.Client{}
req, err := http.NewRequest("POST", urlStr, strings.NewReader("sign=cjb"))
if err != nil {
// handle error
}
// req.Header.Set("Accept", "application/json, text/javascript, */*; q=0.01")
// req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Cookie", "name=anny")
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
fmt.Printf("Body------------------->%v\n", string(body))
}
//上传测试副本
func (f *FileUploadDownload) LongRangeFileUploadES(c *gin.Context) {
// var file example.ExaFileUploadAndDownload
// noSave := c.DefaultQuery("noSave", "0")
var reportStatistics urlData
err := c.ShouldBindJSON(&reportStatistics)
file, errs := c.FormFile("file")
// filePart, header, err := c.Request.FormFile("file")
outPut := commonus.MapOut()
// outPut["filePart"] = filePart
// outPut["header"] = header
// outPut["err"] = err
// outPut["noSave"] = noSave
outPut["file"] = file
outPut["errs"] = errs
// outPut["reportStatistics"] = reportStatistics
// if err != nil {
// // global.GVA_LOG.Error("接收文件失败!", zap.Any("err", err))
// // response.FailWithMessage("接收文件失败", c)
// outPut["msgerr"] = "接收文件失败"
// // return
// } else {
// outPut["msgerr"] = "接收文件成功"
// }
// config := map[string]interface{}{}
// config["Id"] = 0
// config["afa"] = "input"
// config["afa"] = 2
// configdata, _ := json.Marshal(config)
// fmt.Println(config)
// body := bytes.NewBuffer([]byte(configdata))
// configdata, _ := json.Marshal(outPut)
// body := bytes.NewBuffer([]byte(configdata))
// resp, errkjh := http.Post("http://docs.hxgk.group/uploadfileing/uploadimging", "multipart/form-data;charset=utf-8", body)
// outPut["resp"] = resp
// outPut["errkjh"] = errkjh
DataUrlVal := make(map[string]string)
// DataUrlVal.Add("type", strconv.Itoa(reportStatistics.Type))
// DataUrlVal.Add("sign", reportStatistics.Sign)
DataUrlVal["type"] = strconv.Itoa(reportStatistics.Type)
DataUrlVal["sign"] = reportStatistics.Sign
// DataUrlValJson, _ := json.Marshal(DataUrlVal)
// DataUrlVal := url.Values{}
// url := "http://docs.hxgk.group/uploadfileing/uploadimging"
url := "http://docu.hxgk.net/uploadfileing/uploadimging"
// request, err := http.NewRequest("POST", url, strings.NewReader(string(DataUrlValJson)))
// if err != nil {
// response.Result(0, err, "打开链接失败", c)
// fileNameAry := strings.Split(fileHeader.Filename, ".") //拆分文件名称,获取类型及文件原名
// if len(fileNameAry) < 2 {
// response.Result(0, fileHeader, "文件上传错误!", c)
// return
// }
// request.Header.Set("Accept", "application/json, text/javascript, */*; q=0.01")
// // request.Header.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
// request.Header.Add("Accept-Encoding", "gzip, deflate, br")
// request.Header.Add("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4")
// request.Header.Add("Connection", "keep-alive")
// request.Header.Add("Content-Length", "25")
// request.Header.Add("Content-Type", "application/x-www-form-urlencoded")
// request.Header.Add("Cookie", "user_trace_token=20170425200852-dfbddc2c21fd492caac33936c08aef7e; LGUID=20170425200852-f2e56fe3-29af-11e7-b359-5254005c3644; showExpriedIndex=1; showExpriedCompanyHome=1; showExpriedMyPublish=1; hasDeliver=22; index_location_city=%E5%85%A8%E5%9B%BD; JSESSIONID=CEB4F9FAD55FDA93B8B43DC64F6D3DB8; TG-TRACK-CODE=search_code; SEARCH_ID=b642e683bb424e7f8622b0c6a17ffeeb; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1493122129,1493380366; Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1493383810; _ga=GA1.2.1167865619.1493122129; LGSID=20170428195247-32c086bf-2c09-11e7-871f-525400f775ce; LGRID=20170428205011-376bf3ce-2c11-11e7-8724-525400f775ce; _putrc=AFBE3C2EAEBB8730")
// request.Header.Add("Host", "www.lagou.com")
// request.Header.Add("Origin", "https://www.lagou.com")
// request.Header.Add("Referer", "https://www.lagou.com/jobs/list_python?labelWords=&fromSearch=true&suginput=")
// request.Header.Add("X-Anit-Forge-Code", "0")
// request.Header.Add("X-Anit-Forge-Token", "None")
// request.Header.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36")
// request.Header.Add("X-Requested-With", "XMLHttpRequest")
// client := &http.Client{}
// responseww, err := client.Do(request)
localFileSave := "uploads/" + fileHeader.Filename
c.SaveUploadedFile(fileHeader, localFileSave)
// filePath := "G:/goobject/src/git_public/gin-vue-admin/gin_server_admin/go.mod"
// strinUrl := "http://docu.hxgk.net/uploadfileing/uploadimging"
// if err != nil {
// response.Result(102, err, "打开链接失败", c)
// return
// }
// defer responseww.Body.Close()
// body, err := ioutil.ReadAll(responseww.Body)
// outPut["body"] = string(body)
// outPut["DataUrlValJson"] = string(DataUrlValJson)
str, _ := os.Getwd()
filePath := str + "/" + localFileSave //文件转接物理地址
// PostWithFormData("POST", url, &DataUrlVal)
responsesss, err := http.Post(
url,
"application/x-www-form-urlencoded",
strings.NewReader("type=1&age=99"),
)
outPut["err"] = err
defer responsesss.Body.Close()
body, err := ioutil.ReadAll(responsesss.Body)
outPut["body"] = string(body)
httpDo(url)
response.Result(0, outPut, "获取成功", c)
}
outPut := commonus.MapOut()
type JsonPostSample struct {
}
// outPut["fileAttr"] = fileAttr
func (this *JsonPostSample) SamplePost() {
song := make(map[string]interface{})
song["name"] = "李白"
song["timelength"] = 128
song["author"] = "李荣浩"
bytesData, err := json.Marshal(song)
if err != nil {
fmt.Println(err.Error())
fileCallBack := postFormDataWithSingleFile(filePath, urlData.Type)
// outPut["msg"] = fileCallBack.Msg
if fileCallBack.Code != 0 && fileCallBack.Code != 1 {
response.Result(102, outPut, fileCallBack.Msg, c)
return
}
reader := bytes.NewReader(bytesData)
// url := "http://localhost/echo.php"
url := "http://docu.hxgk.net/uploadfileing/uploadimging"
request, err := http.NewRequest("POST", url, reader)
if err != nil {
fmt.Println(err.Error())
return
}
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
client := http.Client{}
resp, err := client.Do(request)
if err != nil {
fmt.Println(err.Error())
return
}
respBytes, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println(err.Error())
return
}
//byte数组直接转成string,优化内存
str := (*string)(unsafe.Pointer(&respBytes))
fmt.Println(*str)
}
func curlShiyan(url string) {
// hsj := httpclient.PostJson()
var fileAttr FileAttribute
//获取文件基础属性
var upLoadFileStruct UpLoadFileStruct
upLoadFileStruct.ID = commonus.GetFileNumberEs()
upLoadFileStruct.CreatedAt = time.Now()
upLoadFileStruct.UpdatedAt = time.Now()
upLoadFileStruct.Key = fileCallBack.Data.NewName
upLoadFileStruct.Name = fileHeader.Filename
upLoadFileStruct.Tag = path.Ext(fileAttr.FileName)
upLoadFileStruct.Url = fileCallBack.Data.Callbackurl
upLoadFileStruct.PhysicsPath = fileCallBack.Data.Physicspath
upLoadFileStruct.FileSize = fileCallBack.Data.GetSize
// outPut["CallBackFileIng"] = postFormDataWithSingleFile(filePath, urlData.Type)
os.RemoveAll(filePath) //删除转接文件
outPut["file"] = upLoadFileStruct
// fmt.Printf("返回值====》%v\n", outPut)
response.Result(0, outPut, fileCallBack.Msg, c)
}

157
gin_server_admin/api/v1/fileuploaddownload/jhk.go

@ -0,0 +1,157 @@
package fileuploaddownload
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"net/url"
"os"
"strings"
)
func httpGet(urlPath string) {
resp, err := http.Get(urlPath)
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
fmt.Printf("Get---------->%v\n", string(body))
// fmt.Println(string(body))
}
func httpPost(urlPath string) {
resp, err := http.Post(urlPath,
"application/x-www-form-urlencoded",
strings.NewReader("key=1&sign=250&file=G:\\goobject\\src\\git_public\\gin-vue-admin\\gin_server_admin\\uploads\\file310dcbbf4cce62f762a2aaa148d556bd_20211222135245.jpg"))
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
// fmt.Println(string(body))
fmt.Printf("Post---------->%v\n", string(body))
}
func httpPostForm(urlPath string) {
resp, err := http.PostForm(urlPath,
url.Values{"key": {"1"}, "sign": {"123"}, "file": {"G:\\goobject\\src\\git_public\\gin-vue-admin\\gin_server_admin\\uploads\\file310dcbbf4cce62f762a2aaa148d556bd_20211222135245.jpg"}})
if err != nil {
// handle error
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
// fmt.Println(string(body))
fmt.Printf("PostForm---------->%v\n", string(body))
}
func httpDoes(urlPath string) {
client := &http.Client{}
req, err := http.NewRequest("POST", urlPath, strings.NewReader("key=1&sign=250&file=G:\\goobject\\src\\git_public\\gin-vue-admin\\gin_server_admin\\uploads\\file310dcbbf4cce62f762a2aaa148d556bd_20211222135245.jpg"))
if err != nil {
// handle error
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
req.Header.Set("Cookie", "name=baidu")
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
// fmt.Println(string(body))
fmt.Printf("NewRequest-----POST----->%v\n", string(body))
}
func postFile(filename string, targetUrl string) error {
bodyBuf := &bytes.Buffer{}
bodyWriter := multipart.NewWriter(bodyBuf)
//关键的一步操作
fileWriter, err := bodyWriter.CreateFormFile("uploadfile", filename)
if err != nil {
fmt.Println("error writing to buffer")
return err
}
//打开文件句柄操作
fh, err := os.Open(filename)
if err != nil {
fmt.Println("error opening file")
return err
}
defer fh.Close()
//iocopy
_, err = io.Copy(fileWriter, fh)
if err != nil {
return err
}
contentType := bodyWriter.FormDataContentType()
bodyWriter.Close()
resp, err := http.Post(targetUrl, contentType, bodyBuf)
if err != nil {
return err
}
defer resp.Body.Close()
resp_body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
// fmt.Println(resp.Status)
// fmt.Println(string(resp_body))
fmt.Printf("NewRequest---%v--POST----->%v\n", resp.Status, string(resp_body))
return nil
}
//创建表单文件
func addFile(urlPath string) {
var buff bytes.Buffer
// 创建一个Writer
writer := multipart.NewWriter(&buff)
writer.WriteField("key", "1")
writer.WriteField("sign", "250")
// 写入图片字段
// CreateFormFile第一个参数是 表单对应的字段名
// 第二个字段是对应上传文件的名称
w, err := writer.CreateFormFile("file", "14250.jpg")
if err != nil {
fmt.Println("创建文件失败: ", err)
return
}
data, err := ioutil.ReadFile("G:\\goobject\\src\\git_public\\gin-vue-admin\\gin_server_admin\\uploads\\file310dcbbf4cce62f762a2aaa148d556bd_20211222135245.jpg")
if err != nil {
fmt.Println("读取图片发生错误: ", err)
return
}
// 把文件内容写入
w.Write(data)
writer.Close()
}

5
gin_server_admin/commonus/jsonStruct.go

@ -11,3 +11,8 @@ type Setwhere struct {
Equation string
Result interface{}
}
type ReturnJson struct {
Code int `json:"code"`
Msg string `json:"msg"`
}

4
gin_server_admin/commonus/mapOutput.go

@ -26,6 +26,10 @@ func MapOutFloat64() (data map[float64]interface{}) {
data = make(map[float64]interface{}) //必可不少,分配内存
return data
}
func MapOutString() (data map[string]string) {
data = make(map[string]string) //必可不少,分配内存
return data
}
func OutPutJson(out_val JsonOut) http.HandlerFunc {
return func(w http.ResponseWriter, req *http.Request) {

49
gin_server_admin/commonus/md5Sub.go

@ -1,10 +1,14 @@
package commonus
import (
"crypto/md5"
"crypto/rand"
"fmt"
"math/big"
"strconv"
"time"
"github.com/flipped-aurora/gin-vue-admin/server/global"
)
// import (
@ -35,3 +39,48 @@ func GetFileNumberEs() (num int64) {
num, _ = strconv.ParseInt(strconv.FormatInt(timeVal, 10)+strconv.FormatInt(result64, 10), 10, 64)
return
}
/*
*加密算法
*/
type Md5Encryption struct {
Code string `json:"code"`
AppKey string `json:"appKey"`
}
func (m *Md5Encryption) Md5EncryptionAlgorithm() (md5Val string) {
if m.AppKey == "" {
m.Md5EncryptionInit(m.Code)
}
// fmt.Printf("Code ====> %v\n", m.Code)
// fmt.Printf("AppKey ====> %v\n", m.AppKey)
mdNew := md5.New()
mdNew.Write([]byte(m.AppKey))
keyMd5 := fmt.Sprintf("%x", mdNew.Sum(nil))
codeNewMd1 := md5.New()
codeNewMd1.Write([]byte(m.Code))
codeMd1 := fmt.Sprintf("%x", codeNewMd1.Sum(nil))
yiCeng := codeMd1 + keyMd5
yiCengNew := md5.New()
yiCengNew.Write([]byte(yiCeng))
yiCengMd5 := fmt.Sprintf("%x", yiCengNew.Sum(nil))
erCeng := yiCengMd5 + m.AppKey
erCengNew := md5.New()
erCengNew.Write([]byte(erCeng))
md5Val = fmt.Sprintf("%x", erCengNew.Sum(nil))
// md5Val = codeMd1
return
}
//初始化程序
func (m *Md5Encryption) Md5EncryptionInit(code string) {
m.AppKey = global.GVA_CONFIG.MyConfig.AppKey
m.Code = code
}

6
gin_server_admin/config.yaml

@ -309,7 +309,9 @@ workwechatappmaillists: #通讯录
healthreports: #健康上报
secretstr: 'smjpGmFo5wp18BZGiLaECFr84Blv429v_GFdKp4_0YQ'
privateConfig: #私人配置
visit: 'http://docu.hxgk.net/uploadfileing/uploadimging'
# visit: 'http://docs.hxgk.group/uploadfileing/uploadimging'
appKey: 'heng_xin_gao_ke_AppKey'

2
gin_server_admin/config/config.go

@ -42,4 +42,6 @@ type Server struct {
WorkWechatSchools workWechatApplication `mapstructure:"workwechatschools" json:"workwechatschools" yaml:"workwechatschools"`
WorkWechatMailLists workWechatSecret `mapstructure:"workwechatappmaillists" json:"workwechatappmaillists" yaml:"workwechatappmaillists"`
WorkHealthReports workWechatSecret `mapstructure:"healthreports" json:"healthreports" yaml:"healthreports"`
MyConfig MyConfigStruct `mapstructure:"privateConfig" json:"privateConfig" yaml:"privateConfig"`
}

6
gin_server_admin/config/privateConfig.go

@ -0,0 +1,6 @@
package config
type MyConfigStruct struct {
Visit string `json:"visit"`
AppKey string `json:"appKey"`
}

3
gin_server_admin/global/global.go

@ -39,4 +39,7 @@ var (
GVA_DB_BillboardDate *gorm.DB
GVA_DB_HealthReport *gorm.DB
GVA_DB_ApprovalProcess *gorm.DB
//个人配置
// GVA_MyConfig config.MyConfig
)

2
gin_server_admin/main.go

@ -79,7 +79,7 @@ func main() {
if global.GVA_DB_ApprovalProcess != nil {
fmt.Printf("%v==>数据库mysqlApprovalProcess初始化成功\n", global.GVA_DB_ApprovalProcess)
}
// fmt.Printf("%v===>%v----->%v\n", global.GVA_CONFIG.WorkWechatId, global.GVA_CONFIG.WorkWechatSchool, global.GVA_CONFIG.WorkWechatMailList)
// fmt.Printf("jkskd => %v===>%v----->%v\n", global.GVA_CONFIG.MyConfig.AppKey, global.GVA_CONFIG.MyConfig.Visit, global.GVA_CONFIG)
// fmt.Printf("%v===>%v----->%v\n", global.GVA_CONFIG.WorkWechatIds, global.GVA_CONFIG.WorkWechatSchools, global.GVA_CONFIG.WorkWechatMailLists)MysqlHealthReportDate
core.RunWindowsServer()

BIN
gin_server_admin/uploads/12221.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
gin_server_admin/uploads/2503.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

BIN
gin_server_admin/uploads/365.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

BIN
gin_server_admin/uploads/file/21deede44c2794d58ccf11ee2de528cd_20211225113512.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

BIN
gin_server_admin/uploads/file/310dcbbf4cce62f762a2aaa148d556bd_20211222135245.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

BIN
gin_server_admin/uploads/file/434d8300ae1b16ca8d70d151289c8376_20211225130904.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
gin_server_admin/uploads/file/56729ce2ce6625d5a10259e2532123e8_20211222132603.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
gin_server_admin/uploads/file/6c9882bbac1c7093bd25041881277658_20211222132541.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
gin_server_admin/uploads/file/6c9882bbac1c7093bd25041881277658_20211222135154.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
gin_server_admin/uploads/file/6c9882bbac1c7093bd25041881277658_20211225130849.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
gin_server_admin/uploads/file/7884a9652e94555c70f96b6be63be216_20211225132701.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

2
web/src/view/example/upload/upload.vue

@ -3,7 +3,7 @@
<div class="gva-table-box">
<div class="gva-btn-list">
<el-upload
:action="`${path}/fileUploadAndDownload/upload`"
:action="`${path}/upordown`"
:before-upload="checkFile"
:headers="{ 'x-token': token }"
:on-error="uploadError"

Loading…
Cancel
Save