🎨优化文件上传机制

This commit is contained in:
coward 2024-07-05 14:52:28 +08:00
parent 2c1450990b
commit 697341f823

View File

@ -29,7 +29,7 @@ func (fileSystem) UploadFile(file []byte, suffix string) (filePath string, err e
return "", err return "", err
} }
return ossObj.LongPath, nil filePath = ossObj.LongPath
case "local": case "local":
filePath = fmt.Sprintf("%v/%d-avatar%s", config.Config.File.Path, time.Now().Unix(), suffix) filePath = fmt.Sprintf("%v/%d-avatar%s", config.Config.File.Path, time.Now().Unix(), suffix)
// 创建目录 // 创建目录
@ -40,8 +40,6 @@ func (fileSystem) UploadFile(file []byte, suffix string) (filePath string, err e
if err = os.WriteFile(filePath, file, os.FileMode(0777)); err != nil { if err = os.WriteFile(filePath, file, os.FileMode(0777)); err != nil {
return "", err return "", err
} }
return filePath, nil
} }
return "", nil return filePath, err
} }