mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
Fix avatar URL.
This commit is contained in:
@ -197,7 +197,7 @@ func (c *ApiController) UploadAvatar() {
|
|||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user.Avatar = fmt.Sprintf("%s%s.png?time=%s", object.GetAvatarPath(), user.Name, util.GetCurrentUnixTime())
|
user.Avatar = fmt.Sprintf("%s%s.png?time=%s", object.GetAvatarPath(), user.GetId(), util.GetCurrentUnixTime())
|
||||||
object.UpdateUser(user.GetId(), user)
|
object.UpdateUser(user.GetId(), user)
|
||||||
resp = Response{Status: "ok", Msg: ""}
|
resp = Response{Status: "ok", Msg: ""}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
|
@ -116,10 +116,11 @@ func UploadAvatar(username string, avatar []byte) string {
|
|||||||
return "oss error"
|
return "oss error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_, err := storage.Put("/casdoor/avatar/" + username + ".png", bytes.NewReader(avatar))
|
|
||||||
|
path := fmt.Sprintf("/casdoor/avatar/%s.png", username)
|
||||||
|
_, err := storage.Put(path, bytes.NewReader(avatar))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
return "oss error"
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user