feat: 支持移动端上传本地照片作为自定义头像,并允许公开读取头像

This commit is contained in:
yml
2026-05-25 09:28:54 +08:00
parent 5d8a009935
commit de4a4ac50e
3 changed files with 117 additions and 9 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ func (h *Handler) writeObject(c *gin.Context, publicOnly bool) {
response.BadRequest(c, "文件 key 不正确")
return
}
if publicOnly && !strings.HasPrefix(key, "home-banner/") {
if publicOnly && !strings.HasPrefix(key, "home-banner/") && !strings.HasPrefix(key, "avatar/") {
response.Error(c, http.StatusNotFound, "not_found", "文件不存在或暂不可访问")
return
}
+1 -1
View File
@@ -50,7 +50,7 @@ func (s *Service) Upload(req uploadRequest) (*UploadDTO, error) {
return nil, err
}
fileURL := "/api/files/object?key=" + url.QueryEscape(key)
if scene == "home-banner" {
if scene == "home-banner" || scene == "avatar" {
fileURL = "/api/public/files/object?key=" + url.QueryEscape(key)
}
return &UploadDTO{