Skip to content
GitLab
菜单
项目
群组
代码片段
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录/注册
切换导航
菜单
打开侧边栏
Libcat
wenyuan-backend
提交
06197dd2
提交
06197dd2
编辑于
6月 13, 2021
作者:
Libcat
👷
浏览文件
修复了用户头像命名规则
上级
19b59bc2
变更
2
Show whitespace changes
Inline
Side-by-side
controllers/api_users.py
浏览文件 @
06197dd2
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
)
...
...
upload/user-admin.jpg
已删除
100644 → 0
浏览文件 @
19b59bc2
编辑
预览
Supports
Markdown
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录