예제 #1
0
        public async Task <IActionResult> GetImage()
        {
            //if (await _profileImageService.GetProfileImage() == null)
            //{
            //    var webRootPath = _hostingEnvironment.WebRootPath + "/img/test3.png";
            //    var bytes = System.IO.File.ReadAllBytes(webRootPath);
            //    return null;

            //}
            //return File( await _profileImageService.GetProfileImage(), "image/*");
            var userName = await _userService.GetloggedinUser();

            return(Ok(Json(new { img = await _profileImageService.GetProfileImage(), userName = userName.UserName })));
        }
예제 #2
0
        public async Task <IActionResult> GetProfileImage()
        {
            Result <FileData> result = await _profileImageService.GetProfileImage(GetUserId());

            if (result.Failure)
            {
                return(NotFound());
            }

            //TODO: make this nicer
            string contentType = "application/octet-stream";

            if (result.Value.FileName.EndsWith(".svg"))
            {
                contentType = "image/svg+xml";
            }

            return(File(result.Value.File, contentType, result.Value.FileName));
        }