public ActionResult File(int id) { var service = new ScribeService(Database, null, null, GetCurrentUser(null, false)); if (!string.IsNullOrEmpty(Request.Headers["If-Modified-Since"])) { var fileInfo = service.GetFile(id); var previousModifiedOn = DateTime.ParseExact(Request.Headers["If-Modified-Since"], "r", CultureInfo.InvariantCulture).ToLocalTime(); var currentModifiedOn = fileInfo.ModifiedOn.TruncateTo(Scribe.Extensions.DateTruncate.Second); if (currentModifiedOn <= previousModifiedOn) { Response.StatusCode = 304; Response.StatusDescription = "Not Modified"; return(Content(string.Empty)); } } var file = service.GetFile(id, true); if (file != null) { Response.Cache.SetCacheability(HttpCacheability.Public); Response.Cache.SetLastModified(file.ModifiedOn); Response.AddHeader("Content-Disposition", "inline; filename=" + file.Name); return(File(file.Data, file.Type)); } Response.AddHeader("Content-Disposition", "inline; filename=404.png"); var data = Assembly.GetExecutingAssembly().ReadEmbeddedBinaryFile("Scribe.Website.Content.404.png"); return(File(data, "image/png")); }
public FileView GetFile(int id, bool includeData) { return(_service.GetFile(id, includeData)); }