refactor: 将分布式锁从 redis 迁移至 utils 包

This commit is contained in:
2026-03-27 09:49:43 +08:00
parent 3cf301275f
commit 0a38df71c9
3 changed files with 42 additions and 38 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
"path/filepath"
"strings"
"time"
"gitea.com/red-future/common/utils"
@@ -53,11 +54,11 @@ func init() {
}
}
func UploadFile(ctx context.Context, fileHeader *ghttp.UploadFile) (imagesUrl string, err error) {
func UploadFile(ctx context.Context, fileHeader *ghttp.UploadFile) (imagesUrl string, fileName string, fileFormat string, err error) {
return uploadFile(ctx, fileHeader)
}
func uploadFile(ctx context.Context, fileHeader *ghttp.UploadFile) (imagesUrl string, err error) {
func uploadFile(ctx context.Context, fileHeader *ghttp.UploadFile) (imagesUrl string, fileName string, fileFormat string, err error) {
bucketName, err := utils.GetBucketName(ctx)
if err != nil {
glog.Errorf(ctx, "获取桶名称失败: %v", err)
@@ -124,5 +125,5 @@ func uploadFile(ctx context.Context, fileHeader *ghttp.UploadFile) (imagesUrl st
glog.Errorf(ctx, "上传图片失败: %v", err)
return
}
return objectName, err
return objectName, fileHeader.Filename, strings.ReplaceAll(fileExt, ".", ""), err
}