public void ProcessRequest(HttpContext context) { using (FilestreamRepository fr = new FilestreamRepository(ConfigurationManager.ConnectionStrings["umbracoDbDSN"].ConnectionString, "Media")) { string path = context.Request.Params["path"]; if (String.IsNullOrEmpty(path)) { // return 404 } string mimeType; MemoryStream s = fr.GetFileStream(path, out mimeType); context.Response.ContentType = mimeType; context.Response.AppendHeader("Content-Length", s.Length.ToString()); context.Response.BinaryWrite(s.ToArray()); } }
public System.IO.Stream OpenFile(string path) { this.Logger.Information("OpenFile({0})", path); path = UmbracoPath.MediaUrlParse(this.HandlerPath, path); using (FilestreamRepository fsr = new FilestreamRepository(this.ConnectionString, this.TableName)) { string mimeType; return fsr.GetFileStream(path, out mimeType); } }