|
<%@ WebHandler Language="C#" Class="Attach" %>
using System;
using System.Web;
public class Attach : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string articleName = context.Request["article"];
string attachName = context.Request["attach"];
string mode = context.Request["mode"];
Eucalypto.Wiki.Article article = Eucalypto.Wiki.WikiManager.GetArticleByName(articleName, true);
if (Eucalypto.SecurityHelper.CanRead(context.User, article.Category, null) == false)
throw new Eucalypto.InvalidPermissionException("Reading file for category " + article.Category.Name);
Eucalypto.Wiki.FileAttachment attachment = Eucalypto.Wiki.WikiManager.GetFileAttachmentByName(article, attachName, true);
if (mode == "download")
{
context.Response.ContentType = "application/x-download";
context.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + attachment.Name + "\"");
}
else
{
context.Response.ContentType = attachment.ContentType;
context.Response.AddHeader("Content-Disposition", "filename=\"" + attachment.Name + "\"");
}
context.Response.OutputStream.Write(attachment.ContentData, 0, attachment.ContentData.Length);
}
public bool IsReusable
{
get
{
return true;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.