diff --git a/model/dto/file_dto.go b/model/dto/file_dto.go index 8788136..9a46121 100644 --- a/model/dto/file_dto.go +++ b/model/dto/file_dto.go @@ -20,5 +20,8 @@ type UploadFile struct { // UploadFileRes 上传文件响应 type UploadFileRes struct { FileURL string `json:"fileURL" dc:"上传地址"` + FileSize int `json:"fileSize" dc:"文件大小"` + FileName string `json:"fileName" dc:"文件名称"` + FileFormat string `json:"fileFormat" dc:"文件格式"` FileAddressPrefix string `json:"fileAddressPrefix"` } diff --git a/service/file_service.go b/service/file_service.go index 79382f7..c82f9d1 100644 --- a/service/file_service.go +++ b/service/file_service.go @@ -39,7 +39,7 @@ func (f *file) UploadFile(ctx context.Context, req *dto.UploadFileReq) (res *dto // 获取redis-租户存储-锁key fileLockKey := fmt.Sprintf(consts.FileLockKey, gconv.String(user.TenantId)) - success, err := redis.Lock(ctx, fileLockKey, gconv.Int64(time.Minute*1), func(ctx context.Context) error { + success, err := utils.Lock(ctx, fileLockKey, gconv.Int64(time.Minute*1), func(ctx context.Context) error { // 获取redis-租户存储容量总数 get, err := redis.RedisClient().Get(ctx, tenantOssTotalKey) if err != nil { @@ -100,7 +100,7 @@ func (f *file) UploadFile(ctx context.Context, req *dto.UploadFileReq) (res *dto return nil, gerror.New("存储服务内存不足") } // 上传图片 - fileURL, err := minio.UploadFile(ctx, req.File) + fileURL, fileName, fileFormat, err := minio.UploadFile(ctx, req.File) if err != nil { glog.Errorf(ctx, "上传图片失败: %v", err) return nil, err @@ -116,7 +116,10 @@ func (f *file) UploadFile(ctx context.Context, req *dto.UploadFileReq) (res *dto } // 返回图片url res = &dto.UploadFileRes{ - FileURL: fileURL, + FileURL: fileURL, + FileSize: fileSize, + FileName: fileName, + FileFormat: fileFormat, } url, err := utils.GetFileAddressPrefix(ctx) if err != nil {