Update the user's avatar image
The JWT token in the 'jwt' cookie is verified by the verifyJWT middleware. If valid, the user's ID is extracted from the token and added to request.body.userId. The uploadImage middleware then handles the file upload. Finally, the updateAvatar controller updates the user's avatar and returns the response.
PATCH
/api/profile/updateavatar
curl \
--request PATCH 'http://localhost:xxxx/api/profile/updateavatar' \
--cookie "jwt=$API_KEY" \
--header "Content-Type: multipart/form-data" \
--form "avatar=@file"
Response examples (200)
{
"avatar": "src/assets/uploads/avatars/1726702800641EcoNex_A10.jpg"
}
Response examples (400)
需要上传图片
Response examples (401)
您未通过身份验证
Response examples (403)
无效的令牌
Response examples (404)
未找到用户
Response examples (500)
服务器内部错误