示例#1
0
        private byte[] getPicture(string photoPath)
        {
            string fileName  = HttpContext.Server.MapPath(photoPath);
            var    imageData = FileBinaryConvertor.GetFile(fileName);

            return(imageData);
        }
示例#2
0
        public FileContentResult UserPhoto(string userID = "")
        {
            ApplicationUser user;

            if (userID == "")
            {
                user = CurrentUser;
            }
            else
            {
                user = db.Users.FirstOrDefault(x => x.Id == userID);
            }

            if (user != null && userHasPhoto(user))
            {
                return(new FileContentResult(user.Photo, "image/jpeg"));
            }
            else
            {
                string fileName  = HttpContext.Server.MapPath(@"~/Content/Images/storyteller.jpg");
                var    imageData = FileBinaryConvertor.GetFile(fileName);

                return(File(imageData, "image/png"));
            }
        }