func (this *SettingsRouter) AvatarSetting() { this.Data["IsUserSettingPage"] = true this.TplNames = "settings/user_avatar.html" //need login if this.CheckLoginRedirect() { return } form := auth.UserAvatarForm{} form.SetFromUser(&this.User) this.SetFormSets(&form) }
func (this *SettingsRouter) AvatarUpload() { this.Data["IsUserSettingPage"] = true this.TplNames = "settings/user_avatar.html" //need login and active if this.CheckLoginRedirect() { return } // get file object file, handler, err := this.Ctx.Request.FormFile("avatar") if err != nil { return } defer file.Close() mime := handler.Header.Get("Content-Type") if err := auth.UploadUserAvatarToQiniu(file, handler.Filename, mime, setting.QiniuAvatarBucket, &this.User); err != nil { return } userAvatarForm := auth.UserAvatarForm{} userAvatarForm.SetFromUser(&this.User) this.SetFormSets(&userAvatarForm) this.FlashRedirect("/settings/avatar", 302, "AvatarUploadSuccess") }