コード例 #1
0
        public async Task <IActionResult> UpdateAvatarViaFile([FromBody] GetUserAvatar avatar)
        {
            if (!ModelState.IsValid)
            {
                return(new BadResponseResult(ModelState));
            }
            var url = await _account.GetUserAvatar(avatar.UserId, avatar.AvatarSizeType);

            return(new OkResponseResult("Avatar URL", new { Url = url }));
        }
コード例 #2
0
 public FileContentResult Get()
 {
     if ((string)Globals.RuntimeSettings["platform"]["os"] == "Windows")
     {
         using (var ms = new MemoryStream())
         {
             Image userAvatarImage = GetUserAvatar.GetUserTile((string)Globals.RuntimeSettings["platform"]["userName"]);
             userAvatarImage.Save(ms, ImageFormat.Jpeg);
             ArraySegment <byte> buffer;
             if (!ms.TryGetBuffer(out buffer))
             {
                 throw new ArgumentException();
             }
             return(File(buffer.Array, "image/png"));
         }
     }
     byte[] filedata = System.IO.File.ReadAllBytes("/wwwroot/img/user_avatar_default.png");
     return(File(filedata, "image/png"));
 }