fix(fe): 修社区图片撑破网格;发帖限 3 张;上传偶发失败自动重试 #5

Merged
Blizzard merged 33 commits from feat/dev into main 2026-07-31 10:43:15 +00:00
Showing only changes of commit 0f3efbc895 - Show all commits
+4 -1
View File
@@ -8,6 +8,7 @@ import (
"io"
"path"
"strings"
"time"
"github.com/sundynix/pets-be/internal/model"
)
@@ -41,7 +42,9 @@ func (s *Service) UploadFile(reader io.Reader, filename, contentType string) (*m
if contentType == "" {
contentType = "application/octet-stream"
}
objectName := "files/" + md5hex + ext
// 按上传月份分文件夹:uploads/2026-07/<md5>.jpg。文件名仍用 md5 保证唯一。
// 同内容命中上面的去重直接复用,不会因为跨月再传一份
objectName := "uploads/" + time.Now().Format("2006-01") + "/" + md5hex + ext
url, err := s.storage.Upload(objectName, bytes.NewReader(data), int64(len(data)), contentType)
if err != nil {
return nil, err