🎨 优化app端文件上传接口

This commit is contained in:
2025-07-31 02:41:39 +08:00
parent 9c51f0cbe4
commit 82c6003b4a
6 changed files with 48 additions and 22 deletions

View File

@@ -2,8 +2,11 @@ package example
import (
"errors"
"git.echol.cn/loser/lckt/utils"
"mime/multipart"
"strconv"
"strings"
"time"
"git.echol.cn/loser/lckt/global"
"git.echol.cn/loser/lckt/model/example"
@@ -94,11 +97,15 @@ func (e *FileUploadAndDownloadService) GetFileRecordInfoList(info request.ExaAtt
func (e *FileUploadAndDownloadService) UploadFile(header *multipart.FileHeader, noSave string, classId int) (file example.ExaFileUploadAndDownload, err error) {
oss := upload.NewOss()
s := strings.Split(header.Filename, ".")
if classId == 2 {
header.Filename = utils.GenerateRandomString(12) + "_" + strconv.FormatInt(time.Now().Unix(), 10) + "." + s[len(s)-1]
}
filePath, key, uploadErr := oss.UploadFile(header)
if uploadErr != nil {
return file, uploadErr
}
s := strings.Split(header.Filename, ".")
f := example.ExaFileUploadAndDownload{
Url: filePath,
Name: header.Filename,