Exemplo n.º 1
0
        public IActionResult ImageResource(Guid id)
        {
            var    resource = imageResourceService.FindById(id);
            string type;

            switch (Path.GetExtension(resource.Path).ToLower())
            {
            case ".jpg":
            case ".jpeg":
                type = "image/jpeg";
                break;

            case ".png":
                type = "image/png";
                break;

            default:
                throw new FormatException("This image format not supported");
            }

            return(File(resource.Image, type));
        }