Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Libcat
wenyuan-backend
Commits
06197dd2
Commit
06197dd2
authored
Jun 13, 2021
by
Libcat
👷
Browse files
修复了用户头像命名规则
parent
19b59bc2
Changes
2
Show whitespace changes
Inline
Side-by-side
controllers/api_users.py
View file @
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
deleted
100644 → 0
View file @
19b59bc2
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment