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