public ActionResult Show(Guid id) { var imageData = ImgStore.GetImg(id); ImgStore.Show(id); return(File(imageData.ImgBytes, "image/jpg")); }
public ActionResult Index(HttpPostedFileBase file, int maxShow = 2) { if (file != null && file.ContentLength > 0) { bool ok = true; if (Path.GetExtension(file.FileName).ToLower() != ".jpg") { ok = false; ViewBag.format = "Only jpg..."; } if (file.ContentLength > 2000 * 1024) { ok = false; ViewBag.size = "2MB max"; } if (maxShow > 10) { ok = false; ViewBag.error = "I don't think so"; } if (ok) { byte[] imgBytes = new byte[file.ContentLength]; file.InputStream.Read(imgBytes, 0, file.ContentLength); var img = ImgStore.AddImg(imgBytes, maxShow); ViewBag.result = img.Id; } } return(View()); }
// GET: Img public ActionResult Index(string id) { Guid imageId; if (Guid.TryParse(id, out imageId) && ImgStore.ImgExists(imageId)) { ViewBag.img = imageId.ToString(); } else { return(View("Nothing")); } return(View()); }
public ActionResult List() { var list = ImgStore.List(); return(View(list)); }