制作ppt文件保存已存在文件添加时间戳防止文件重名

This commit is contained in:
junleea 2025-04-07 19:22:59 +08:00
parent 64d5977f7e
commit e960783f5b
1 changed files with 4 additions and 1 deletions

View File

@ -253,7 +253,10 @@ func CreateUserFile(userID int, fileAuthName string, fileID int, UploadType stri
log.Println("file auth name already exist, please change another name: ", fileAuthName)
//将要保存的文件名改为fileAuthName+uuid
strs := strings.Split(fileAuth.UserFileName, ".")
fileAuthName = strs[0] + "_1." + strs[1]
//当前时间戳
timestamp := time.Now().Unix()
timestampStr := fmt.Sprintf("%d", timestamp)
fileAuthName = strs[0] + "_" + timestampStr + "." + strs[1]
//return fileAuth
}
fileAuth_ := dao.CreateFileAuth(userID, fileID, fileAuthName, UploadType, 1, "")