Add SetProfileImage for plugin API (#9831)
Этот коммит содержится в:
коммит произвёл
Hanzei
родитель
f0351f23f1
Коммит
b29f1cb844
11
app/user.go
11
app/user.go
@@ -801,10 +801,10 @@ func (a *App) SetProfileImage(userId string, imageData *multipart.FileHeader) *m
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.open.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
defer file.Close()
|
||||
return a.SetProfileImageFromFile(userId, file)
|
||||
return a.SetProfileImageFromMultiPartFile(userId, file)
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromFile(userId string, file multipart.File) *model.AppError {
|
||||
func (a *App) SetProfileImageFromMultiPartFile(userId string, file multipart.File) *model.AppError {
|
||||
// Decode image config first to check dimensions before loading the whole thing into memory later on
|
||||
config, _, err := image.DecodeConfig(file)
|
||||
if err != nil {
|
||||
@@ -816,14 +816,17 @@ func (a *App) SetProfileImageFromFile(userId string, file multipart.File) *model
|
||||
|
||||
file.Seek(0, 0)
|
||||
|
||||
return a.SetProfileImageFromFile(userId, file)
|
||||
}
|
||||
|
||||
func (a *App) SetProfileImageFromFile(userId string, file io.Reader) *model.AppError {
|
||||
|
||||
// Decode image into Image object
|
||||
img, _, err := image.Decode(file)
|
||||
if err != nil {
|
||||
return model.NewAppError("SetProfileImage", "api.user.upload_profile_user.decode.app_error", nil, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
file.Seek(0, 0)
|
||||
|
||||
orientation, _ := getImageOrientation(file)
|
||||
img = makeImageUpright(img, orientation)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user