fixed user custom avatar location

This commit is contained in:
Zurdi
2024-02-09 12:51:52 +01:00
parent 2cf073cff9
commit 0b3b353937
2 changed files with 3 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ from endpoints.responses.identity import UserSchema
from fastapi import APIRouter, Depends, HTTPException, Request, status
from handler import auth_handler, db_user_handler, fs_asset_handler
from models.user import Role, User
from config import ASSETS_BASE_PATH
router = APIRouter()
@@ -133,7 +134,7 @@ def update_user(
user_avatar_path = fs_asset_handler.build_avatar_path(user=user)
file_location = f"{user_avatar_path}/{form_data.avatar.filename}"
cleaned_data["avatar_path"] = file_location
with open(file_location, "wb+") as file_object:
with open(f"{ASSETS_BASE_PATH}/{file_location}", "wb+") as file_object:
file_object.write(form_data.avatar.file.read())
if cleaned_data:

View File

@@ -36,9 +36,7 @@ class FSAssetsHandler(FSHandler):
# /users/557365723a31/profile
def build_avatar_path(self, user: User):
user_avatar_path = os.path.join(
ASSETS_BASE_PATH, self.user_folder_path(user), "profile"
)
user_avatar_path = os.path.join(self.user_folder_path(user), "profile")
Path(user_avatar_path).mkdir(parents=True, exist_ok=True)
return user_avatar_path