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:
@@ -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": [
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.ProfileDto"
|
||||
"$ref": "#/definitions/dto.NewProfileDto"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -328,42 +328,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/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": [
|
||||
@@ -491,14 +455,97 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/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"
|
||||
@@ -546,17 +593,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.UrlDto": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"url"
|
||||
],
|
||||
"properties": {
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.ChangePasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -659,6 +695,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.PresignedUploadResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"fields": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models.RefreshRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user