public ActionResult Get([FromQuery] int imageId)
        {
            UploadedFileDto image = _uploadedFileRepository.Get(imageId);

            if (image == null)
            {
                _basicPresenter.Handle(new Error(404, "image not found"));
            }
            string filePath = GetPhysicalPathFromRelativeUrl(image.RelativePath);

            _imagePresenter.Handle(Convert.ToBase64String(System.IO.File.ReadAllBytes(filePath)));
            return(_imagePresenter.ContentResult);

            /*FileStream imageFile = System.IO.File.OpenRead(filePath);
             * var file = File(imageFile, $"image/{Path.GetExtension(filePath).Substring(1)}", "image.jpg");
             * return new { file = file };*/
        }
Example #2
0
 public UploadedFile Get(Guid id)
 {
     return(_uploadedFileRepository.Get(id));
 }