From b565b72cd3063db2f0e68a7fa686b3805b722080 Mon Sep 17 00:00:00 2001 From: wenjianzhang Date: Tue, 25 May 2021 19:37:19 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E2=9C=A8=20=E4=B8=8A=E4=BC=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8E=BB=E6=8E=89=E9=BB=98=E8=AE=A4=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/other/apis/file.go | 43 +++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/app/other/apis/file.go b/app/other/apis/file.go index d9af900..187dc95 100644 --- a/app/other/apis/file.go +++ b/app/other/apis/file.go @@ -45,28 +45,33 @@ func (e File) UploadFile(c *gin.Context) { tag, _ := c.GetPostForm("type") urlPrefix := fmt.Sprintf("http://%s/", c.Request.Host) var fileResponse FileResponse - if tag == "" { - e.Error(500, nil, "缺少标识") - return - } else { - switch tag { - case "1": // 单图 - var done bool - fileResponse, done = e.singleFile(c, fileResponse, urlPrefix) - if done { - return - } - e.OK(fileResponse, "上传成功") + + switch tag { + case "1": // 单图 + var done bool + fileResponse, done = e.singleFile(c, fileResponse, urlPrefix) + if done { return - case "2": // 多图 - multipartFile := e.multipleFile(c, urlPrefix) - e.OK(multipartFile, "上传成功") - return - case "3": // base64 - fileResponse = e.baseImg(c, fileResponse, urlPrefix) - e.OK(fileResponse, "上传成功") } + e.OK(fileResponse, "上传成功") + return + case "2": // 多图 + multipartFile := e.multipleFile(c, urlPrefix) + e.OK(multipartFile, "上传成功") + return + case "3": // base64 + fileResponse = e.baseImg(c, fileResponse, urlPrefix) + e.OK(fileResponse, "上传成功") + default: + var done bool + fileResponse, done = e.singleFile(c, fileResponse, urlPrefix) + if done { + return + } + e.OK(fileResponse, "上传成功") + return } + } func (e File) baseImg(c *gin.Context, fileResponse FileResponse, urlPerfix string) FileResponse {