asp.net 大文件上传 之 改版了的SlickUpload.HttpUploadModule(Krystalwar

2019-05-12 01:22:52刘景俊

if (!IsGoOn(application1)) return;
//end
if (this.IsUploadRequest(application1.Request))
{
HttpWorkerRequest request1 = this.GetWorkerRequest(application1.Context);
Encoding encoding1 = application1.Context.Request.ContentEncoding;
if (request1 != null)
{
byte[] buffer1 = this.ExtractBoundary(application1.Request.ContentType, encoding1);
string text1 = application1.Request.QueryString["uploadId"];
MimeUploadHandler handler1 = new MimeUploadHandler(new RequestStream(request1), buffer1, text1, encoding1);
if (text1 != null)
{
this.RegisterIn(application1.Context, handler1);
}
try
{
this.SetUploadState(application1.Context, UploadState.ReceivingData);
handler1.Parse();
this.InjectTextParts(request1, encoding1.GetBytes(handler1.TextParts));
}
catch (DisconnectedException)
{
this.CleanupFiles(application1.Context);
}
}
}
}
/// <summary>
/// 当没有设置[HttpUploadModulePageJump]则返回false;
/// 当设置[HttpUploadModulePageJump]中有[*.*;]时则返回true
/// 当设置[HttpUploadModulePageJump]中的页面等同与所要处理页面的后缀时,则返回true,否则返回false
/// </summary>
/// <param name="application1"></param>
/// <returns></returns>
private bool IsJump(HttpApplication application1)
{
bool result = false;
if (application1.Application["HttpUploadModulePageJump"] != null)
{
string[] al = ((string)application1.Application["HttpUploadModulePageJump"]).Split(';');
if (al != null )
{
for(int i = 0; i < al.Length; i++)
{
string temp= al[i];//"OfficeServer.aspx";
if (temp =="*.*")
{
result = true;
break;
}
if (application1.Request.Path.EndsWith(temp))
{
result = true;
break;
}
}
}
}
return result;
}
/// <summary>
/// 当没有设置[HttpUploadModulePageGoOn]则返回false;
/// 当设置[HttpUploadModulePageGoOn]中有[*.*;]时则返回true
/// 当设置[HttpUploadModulePageGoOn]中的页面等同与所要处理页面的后缀时,则返回true,否则返回false
/// </summary>
/// <param name="application1"></param>
/// <returns></returns>
private bool IsGoOn(HttpApplication application1)
{
bool result = false;
if (application1.Application["HttpUploadModulePageGoOn"] != null)
{
string[] al = ((string)application1.Application["HttpUploadModulePageGoOn"]).Split(';');
if (al != null)
{
for(int i = 0; i < al.Length; i++)
{
string temp= al[i];//"OfficeServer.aspx";
if (temp =="*.*")
{
result = true;
break;
}
if (application1.Request.Path.EndsWith(temp))
{
result = true;
break;
}
}
}
}
return result;
}
private void context_EndRequest(object sender, EventArgs e)
{
HttpApplication application1 = sender as HttpApplication;
//begin: 2005.10.15+
//如果满足<HttpUploadModulePageJump>所设置的页面,则不使用大文件上传功能,直接跳出