chore: remove direct avatar upload endpoint (POST /profile/avatar);

feat: add endpoints for presigned upload URLs (GET /upload/avatar, GET /upload/image);
refactor: replace ProfileDto with NewProfileDto in update profile endpoint;
feat: implement S3 integration for avatar management;
fix: update database queries to handle new avatar upload flow;
chore: add new dependencies for S3 handling (golang.org/x/time);
refactor: rename UploadService to S3Service;
refactor: change return type for func LocalizeS3Url(originalURL string) (*url.URL, error);
feat: add custom validator for upload_id
This commit is contained in:
2025-08-01 04:34:06 +03:00
parent 8dba0f79aa
commit 669349e020
15 changed files with 405 additions and 222 deletions

View File

@@ -1,5 +1,22 @@
basePath: /api/
definitions:
dto.NewProfileDto:
properties:
avatar_upload_id:
type: string
bio:
type: string
birthday:
type: integer
color:
type: string
color_grad:
type: string
name:
type: string
required:
- name
type: object
dto.ProfileDto:
properties:
avatar_url:
@@ -14,8 +31,6 @@ definitions:
type: string
name:
type: string
required:
- name
type: object
dto.ProfileSettingsDto:
properties:
@@ -34,13 +49,6 @@ definitions:
hide_profile_details:
type: boolean
type: object
dto.UrlDto:
properties:
url:
type: string
required:
- url
type: object
models.ChangePasswordRequest:
properties:
old_password:
@@ -109,6 +117,15 @@ definitions:
refresh_token:
type: string
type: object
models.PresignedUploadResponse:
properties:
fields:
additionalProperties:
type: string
type: object
url:
type: string
type: object
models.RefreshRequest:
properties:
refresh_token:
@@ -351,7 +368,7 @@ paths:
name: request
required: true
schema:
$ref: '#/definitions/dto.ProfileDto'
$ref: '#/definitions/dto.NewProfileDto'
produces:
- application/json
responses:
@@ -390,28 +407,6 @@ paths:
summary: Get profile by username
tags:
- Profile
/profile/avatar:
post:
consumes:
- multipart/form-data
parameters:
- description: Avatar image file
in: formData
name: file
required: true
type: file
produces:
- application/json
responses:
"200":
description: Uploaded image url
schema:
$ref: '#/definitions/dto.UrlDto'
security:
- JWT: []
summary: Upload an avatar
tags:
- Profile
/profile/settings:
get:
consumes:
@@ -465,6 +460,42 @@ paths:
summary: Get health status
tags:
- Service
/upload/avatar:
get:
consumes:
- application/json
produces:
- application/json
responses:
"200":
description: Presigned URL and form data
schema:
$ref: '#/definitions/models.PresignedUploadResponse'
"500":
description: Internal server error
security:
- JWT: []
summary: Get presigned URL for avatar upload
tags:
- Upload
/upload/image:
get:
consumes:
- application/json
produces:
- application/json
responses:
"200":
description: Presigned URL and form data
schema:
$ref: '#/definitions/models.PresignedUploadResponse'
"500":
description: Internal server error
security:
- JWT: []
summary: Get presigned URL for image upload
tags:
- Upload
schemes:
- http
securityDefinitions: