|
@@ -124,7 +124,7 @@ func (this *ImageController) Base64Upload() {
|
|
|
sign := this.GetString("Sign")
|
|
|
checkSign := "dIGi2M0VN21s3dKS"
|
|
|
if sign != checkSign {
|
|
|
- br.Msg = "前面错误"
|
|
|
+ br.Msg = "签名错误"
|
|
|
return
|
|
|
}
|
|
|
imgData := this.GetString("Img")
|
|
@@ -147,7 +147,7 @@ func (this *ImageController) Base64Upload() {
|
|
|
}
|
|
|
var saveToOssPath string
|
|
|
randStr := utils.GetRandStringNoSpecialChar(28)
|
|
|
- var fileName, savePath, svgPath, outPath, outFileName string
|
|
|
+ var fileName, savePath, svgPath, outFileName string
|
|
|
fileName = randStr + ".svg"
|
|
|
savePath = uploadDir + "/" + fileName
|
|
|
svgPath = savePath
|
|
@@ -157,18 +157,21 @@ func (this *ImageController) Base64Upload() {
|
|
|
br.ErrMsg = "图片保存失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- outFileName = randStr + ".png"
|
|
|
- outPath = uploadDir + "/" + randStr + ".png"
|
|
|
+ hzUploadDir := "static/images/"
|
|
|
+ outFileName = hzUploadDir + randStr + ".png"
|
|
|
+ fmt.Println("start convert", time.Now())
|
|
|
cd := exec.Command("highcharts-export-server", "--infile", svgPath, "--constr", "Chart", "--scale", "2", "--outfile", outFileName)
|
|
|
str, err := cd.Output()
|
|
|
fmt.Println(string(str))
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|
|
|
}
|
|
|
- if outPath != "" {
|
|
|
- savePath = outPath
|
|
|
- }
|
|
|
- hzUploadDir := "static/images/"
|
|
|
+ fmt.Println("end convert", time.Now())
|
|
|
+ savePath = outFileName
|
|
|
+ defer func() {
|
|
|
+ os.Remove(svgPath)
|
|
|
+ os.Remove(outFileName)
|
|
|
+ }()
|
|
|
saveToOssPath = hzUploadDir + time.Now().Format("200601/20060102/")
|
|
|
saveToOssPath += outFileName
|
|
|
//上传到阿里云
|
|
@@ -178,10 +181,6 @@ func (this *ImageController) Base64Upload() {
|
|
|
br.ErrMsg = "文件上传失败,Err:" + err.Error()
|
|
|
return
|
|
|
}
|
|
|
- defer func() {
|
|
|
- os.Remove(svgPath)
|
|
|
- os.Remove(outFileName)
|
|
|
- }()
|
|
|
fileHost := "https://hzstatic.hzinsights.com/"
|
|
|
resourceUrl := fileHost + saveToOssPath
|
|
|
resp := new(models.ResourceResp)
|