Commit 06197dd2 authored by Libcat's avatar Libcat 👷
Browse files

修复了用户头像命名规则

parent 19b59bc2
import uuid
from typing import List, Optional
import arrow
from fastapi import APIRouter, Response, Form, Depends, UploadFile
from pathlib import Path
import apischemas as api
......@@ -38,7 +38,7 @@ async def create_user(username: str = Form(...),
# 获取图片后缀
if suffix == "" or suffix == None:
suffix = ".jpg"
filename = f"user-{username}{suffix}"
filename = f"user-{arrow.now().int_timestamp}{suffix}"
# 保存图片
with open("upload/" + filename, 'wb') as f:
f.write(content)
......@@ -99,7 +99,7 @@ async def change_user_profile(email: str = Form(None),
# 获取图片后缀
if suffix == "" or suffix == None:
suffix = ".jpg"
filename = f"user-{user.username}{suffix}"
filename = f"user-{arrow.now().int_timestamp}{suffix}"
# 保存图片
with open("upload/" + filename, 'wb') as f:
f.write(content)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment