using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Formulieren.Pages
{
    public class ImageModel : PageModel
    {
        private IWebHostEnvironment _webHostEnvironment;
        public ImageModel(IWebHostEnvironment webHostEnvironment)
        {
            _webHostEnvironment = webHostEnvironment;
        }

        public IActionResult OnGet(string filename)
        {
            var bestand = Path.Combine(_webHostEnvironment.ContentRootPath, "uploads", filename);
            return PhysicalFile(bestand, "image/jpg");
        }
    }
}