提交 06197dd2 编辑于 作者: Libcat's avatar Libcat 👷
浏览文件

修复了用户头像命名规则

上级 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)
......
Supports Markdown
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册