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

@@ -318,7 +318,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.ProfileDto"
"$ref": "#/definitions/dto.NewProfileDto"
}
}
],
@@ -332,42 +332,6 @@ const docTemplate = `{
}
}
},
"/profile/avatar": {
"post": {
"security": [
{
"JWT": []
}
],
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"Profile"
],
"summary": "Upload an avatar",
"parameters": [
{
"type": "file",
"description": "Avatar image file",
"name": "file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "Uploaded image url",
"schema": {
"$ref": "#/definitions/dto.UrlDto"
}
}
}
}
},
"/profile/settings": {
"get": {
"security": [
@@ -495,14 +459,97 @@ const docTemplate = `{
}
}
}
},
"/upload/avatar": {
"get": {
"security": [
{
"JWT": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Upload"
],
"summary": "Get presigned URL for avatar upload",
"responses": {
"200": {
"description": "Presigned URL and form data",
"schema": {
"$ref": "#/definitions/models.PresignedUploadResponse"
}
},
"500": {
"description": "Internal server error"
}
}
}
},
"/upload/image": {
"get": {
"security": [
{
"JWT": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Upload"
],
"summary": "Get presigned URL for image upload",
"responses": {
"200": {
"description": "Presigned URL and form data",
"schema": {
"$ref": "#/definitions/models.PresignedUploadResponse"
}
},
"500": {
"description": "Internal server error"
}
}
}
}
},
"definitions": {
"dto.ProfileDto": {
"dto.NewProfileDto": {
"type": "object",
"required": [
"name"
],
"properties": {
"avatar_upload_id": {
"type": "string"
},
"bio": {
"type": "string"
},
"birthday": {
"type": "integer"
},
"color": {
"type": "string"
},
"color_grad": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"dto.ProfileDto": {
"type": "object",
"properties": {
"avatar_url": {
"type": "string"
@@ -550,17 +597,6 @@ const docTemplate = `{
}
}
},
"dto.UrlDto": {
"type": "object",
"required": [
"url"
],
"properties": {
"url": {
"type": "string"
}
}
},
"models.ChangePasswordRequest": {
"type": "object",
"required": [
@@ -663,6 +699,20 @@ const docTemplate = `{
}
}
},
"models.PresignedUploadResponse": {
"type": "object",
"properties": {
"fields": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"url": {
"type": "string"
}
}
},
"models.RefreshRequest": {
"type": "object",
"required": [