mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Support username arg in UploadResource().
This commit is contained in:
parent
2b6f397bb9
commit
91c0282040
@ -111,6 +111,11 @@ func (c *ApiController) UploadResource() {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if username == "" || fullFilePath == "" {
|
||||
c.ResponseError(fmt.Sprintf("username or fullFilePath is empty: username = %s, fullFilePath = %s", username, fullFilePath))
|
||||
return
|
||||
}
|
||||
|
||||
filename := filepath.Base(fullFilePath)
|
||||
fileBuffer := bytes.NewBuffer(nil)
|
||||
if _, err = io.Copy(fileBuffer, file); err != nil {
|
||||
@ -161,8 +166,11 @@ func (c *ApiController) UploadResource() {
|
||||
switch tag {
|
||||
case "avatar":
|
||||
if user == nil {
|
||||
c.ResponseError("user is nil for tag: \"avatar\"")
|
||||
return
|
||||
user = object.GetUser(username)
|
||||
if user == nil {
|
||||
c.ResponseError("user is nil for tag: \"avatar\"")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
user.Avatar = fileUrl
|
||||
|
Loading…
x
Reference in New Issue
Block a user