🎨 优化app端文件上传接口
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user