Browse Source

修改重定向地址

pull/3033/head
ychao_1983 2 years ago
parent
commit
e91dbdbcdd
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      routers/modelapp/desensitization.go

+ 5
- 4
routers/modelapp/desensitization.go View File

@@ -17,6 +17,7 @@ import (


var restyClient *resty.Client var restyClient *resty.Client
var tplExploreUpload base.TplName = "model/tuomin/upload" var tplExploreUpload base.TplName = "model/tuomin/upload"
var uploadUrl string = "/extension/tuomin/upload"
var allowedContentType = []string{"image/jpeg", "image/jpg", "image/png"} var allowedContentType = []string{"image/jpeg", "image/jpg", "image/png"}


func ProcessImageUI(ctx *context.Context) { func ProcessImageUI(ctx *context.Context) {
@@ -28,7 +29,7 @@ func ProcessImage(ctx *context.Context) {
file, header, err := ctx.GetFile("file") file, header, err := ctx.GetFile("file")
if err != nil { if err != nil {
ctx.Flash.Error(ctx.Tr("model_app.get_file_fail")) ctx.Flash.Error(ctx.Tr("model_app.get_file_fail"))
ctx.Redirect(setting.AppSubURL + "/" + string(tplExploreUpload))
ctx.Redirect(setting.AppSubURL + uploadUrl)
return return
} }
defer file.Close() defer file.Close()
@@ -37,7 +38,7 @@ func ProcessImage(ctx *context.Context) {


if !isInAllowedContentType(contentType) { if !isInAllowedContentType(contentType) {
ctx.Flash.Error(ctx.Tr("model_app.content_type_unsupported")) ctx.Flash.Error(ctx.Tr("model_app.content_type_unsupported"))
ctx.Redirect(setting.AppSubURL + "/" + string(tplExploreUpload))
ctx.Redirect(setting.AppSubURL + uploadUrl)
return return
} }


@@ -46,13 +47,13 @@ func ProcessImage(ctx *context.Context) {
"file", header.Filename, contentType, file).Post(setting.ModelApp.DesensitizationUrl + "?mode=" + strconv.Itoa(ctx.QueryInt("mode"))) "file", header.Filename, contentType, file).Post(setting.ModelApp.DesensitizationUrl + "?mode=" + strconv.Itoa(ctx.QueryInt("mode")))
if err != nil { if err != nil {
ctx.Flash.Error(ctx.Tr("model_app.process_image_fail")) ctx.Flash.Error(ctx.Tr("model_app.process_image_fail"))
ctx.Redirect(setting.AppSubURL + "/" + string(tplExploreUpload))
ctx.Redirect(setting.AppSubURL + uploadUrl)
return return
} }
image, _, err := image.Decode(bytes.NewReader(res.Body())) image, _, err := image.Decode(bytes.NewReader(res.Body()))
if err != nil { if err != nil {
ctx.Flash.Error(ctx.Tr("model_app.process_image_fail")) ctx.Flash.Error(ctx.Tr("model_app.process_image_fail"))
ctx.Redirect(setting.AppSubURL + "/" + string(tplExploreUpload))
ctx.Redirect(setting.AppSubURL + uploadUrl)
return return
} }




Loading…
Cancel
Save