修改类型
This commit is contained in:
parent
611dffa4e0
commit
3eba71e7a0
@ -80,15 +80,12 @@ func (b *Editor) EditorUpload(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fileType := c.PostForm("type")
|
fileType := "jpg"
|
||||||
if fileType == "" {
|
if file.Filename != "" {
|
||||||
responses.FailWithMessage("缺少参数", c)
|
fileType = utils.GetExtension(fileType)
|
||||||
return
|
if fileType == "" {
|
||||||
}
|
fileType = "jpg"
|
||||||
|
}
|
||||||
fileType = utils.GetExtension(fileType)
|
|
||||||
if fileType == "" {
|
|
||||||
fileType = "jpg"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|||||||
@ -21,10 +21,10 @@ func AddOssDomain(url string) string {
|
|||||||
return config.C.Oss.OssCustomDomainName + url
|
return config.C.Oss.OssCustomDomainName + url
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetExtension 解析并返回字符串中 `/` 后面的部分
|
// GetExtension 解析并返回字符串中 `.` 后面的部分
|
||||||
func GetExtension(s string) string {
|
func GetExtension(s string) string {
|
||||||
// 使用 strings.Split 分割字符串
|
// 使用 strings.Split 分割字符串
|
||||||
parts := strings.Split(s, "/")
|
parts := strings.Split(s, ".")
|
||||||
if len(parts) > 1 {
|
if len(parts) > 1 {
|
||||||
return parts[1] // 返回第二部分
|
return parts[1] // 返回第二部分
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user