private ActionResult PrepareFileResult(IReport report, string ext, bool download, byte[] renderedBytes, ReportRegistry.Report reportInfo) { string fileDownloadName; var customFileName = report as ICustomFileName; if (customFileName != null) { fileDownloadName = customFileName.GetFileName(); } else { fileDownloadName = (reportInfo.Title ?? reportInfo.Key) + "_" + DateTime.Now.ToString("yyyyMMdd_HHss"); } fileDownloadName += "." + ext; if (download) { return(new FileContentResult(renderedBytes, "application/octet-stream") { FileDownloadName = fileDownloadName }); } Response.Headers["Content-Disposition"] = "inline;filename=" + System.Net.WebUtility.UrlEncode(fileDownloadName); return(File(renderedBytes, KnownMimeTypes.Get(fileDownloadName))); }
public ActionResult Read(string pathInfo) { UploadPathHelper.CheckFileNameSecurity(pathInfo); if (!UploadStorage.FileExists(pathInfo)) { return(new NotFoundResult()); } var mimeType = KnownMimeTypes.Get(pathInfo); var stream = UploadStorage.OpenFile(pathInfo); return(new FileStreamResult(stream, mimeType)); }