示例#1
0
        public async Task <ActionResult <ImageDTO> > GetImage(int id)
        {
            // Image image =  repository.Get(id);
            Image image = await repository.GetAsync(id);

            if (image == null)
            {
                return(NotFound());
            }
            else
            {
                Byte[] b = System.IO.File.ReadAllBytes(image.ImgUrl); // You can use your own method over here.
                string base64ImageRepresentation = "data:image/jpeg;base64," + Convert.ToBase64String(b);
                //var file = File(b, "image/jpeg;base64", image.ImgName);

                ImageDTO img = new ImageDTO
                {
                    imageId        = image.ImageId,
                    imgName        = image.ImgName,
                    imgDescription = image.ImgDescription,
                    platform       = image.PlatformId,
                    imgUrl         = base64ImageRepresentation
                };

                return(Ok(img));
            }
        }
示例#2
0
 public async Task <Image> GetAsync(Guid id)
 {
     return(await _imagesRepository.GetAsync(id));
 }