Big file upload research

xiaoxiao2021-03-06  66

This time, in the project, it is uploaded by large files. The file to be uploaded has more than 100 m, so it is more useful to find a large number of components that have been uploaded in China. There are two controls ASPNETUPLOAD 2.0 and Lion.Web.uploadModule In addition, there is also the way to think in its blog Hall http://blog.joycode.com/saucer/archive/2004/03/16/16225.aSPX method for two controls: Utilization HTTPWORKERREQUEST, uses its getPreLoadedEntityBody and ReadentityBody methods to read data from IIS to the PIPE established by IIS asP.Net. Chris Hynes provides us with such a solution (with httpmodule), which can display upload progress in real time in addition to allowing you to upload large files. Lion.Web.uploadModule and ASPNETUPLOAD two .NET components are using this solution. When uploading single files, two methods are the same software, inheritance HttpModule HttpApplication application1 = sender as HttpApplication; HttpWorkerRequest request1 = (HttpWorkerRequest) ((IServiceProvider) HttpContext.Current) .GetService (typeof (HttpWorkerRequest)); try {if (Application1.Context.request.contettype.indexof ("Multipart / Form-Data") <= -1) {Return;} // check the HasentityBody IF (! Request1.haseTyBody ()) {Return;}

INT NUM1 = 0; timeespan span1 = datetime.now.subtract (this.begintime);

String text1 = Application1.context.Request.conteType.tolower ();

Byte [] buffer1 = encoding.ascii.getbytes (("/ r / n--" text1.substring (Text1.indexof ("Boundary =") 9))). TocharaRray ()); int Num2 = Convert.Toint32 (Request1.getknownRequestHeader (11)); progress progress1 = new progress ();

Application1.context.Items.Add ("FileList", new hashtable ());

Byte [] buffer2 = Request1.getPreLoadededEntityBody (); Num1 = buffer2.Length

string text2 = this.AnalysePreloadedEntityBody (buffer2, "UploadGUID"); if (text2 = string.Empty!) {application1.Context.Items.Add ( "LionSky_UpLoadModule_UploadGUID", text2);} bool flag1 = true; if ((num2> THIS.UPLOADFILENGTH () && ((0> span1.totalhai) || (span1.totalhai> 3)))) {flag1 = false;} = f ((0> span1.totalhai) || (span1.totalhai> 3) ) {flag1 = false;} string text3 = this.AnalysePreloadedEntityBody (buffer2, "UploadFolder"); ArrayList list1 = new ArrayList (); RequestStream stream1 = new RequestStream (buffer2, buffer1, null, RequestStream.FileStatus.Close, RequestStream.ReadStatus .NoRead, text3, flag1, application1.Context, string.Empty); list1.AddRange (stream1.ReadBody); if (text2 = string.Empty) {progress1.FileLength = num2;! progress1.ReceivedLength = num1; progress1.FileName = stream1.originalFileName; progress1.filecount = (Hashtable) Application1.context.Items ["filelist"]). count; application1.Application [ "_ UploadGUID_" text2] = progress1;} if (request1.IsEntireEntityBodyIsPreloaded ()!) {byte [] buffer4; ArrayList list2; int num3 = 204800; byte [] buffer3 = new byte [num3]; while ( (num2 - num1)> = num3) {if (application1.Context.Response.IsClientConnected) {this.ClearApplication (application1);} num3 = request1.ReadEntityBody (buffer3, buffer3.Length); num1 = num3; list2 =! Stream1.contentBody; if (list2.count> 0) {buffer4 = new byte [list2.count buffer3.length];

list2.CopyTo (buffer4, 0); buffer3.CopyTo (buffer4, list2.Count); stream1 = new RequestStream (buffer4, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1 .OriginalFileName);} else {stream1 = new RequestStream (buffer3, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1.OriginalFileName);} list1.AddRange (stream1.ReadBody) ; if (text2 = string.Empty!) {progress1.ReceivedLength = num1; progress1.FileName = stream1.OriginalFileName; progress1.FileCount = ((Hashtable) application1.Context.Items [ "FileList"]) Count;. application1.Application [ "_UploadGUID_" text2] = progress1;}} buffer3 = new byte [num2 - num1]; if {this.ClearApplication (application1.Context.Response.IsClientConnected && (stream1.FStatus == RequestStream.FileStatus.Open)!) (Application1); Num3 = Request1 .ReadentityBody (Buffer3, Buffer3.Length); List2 = stream1.contentBody; if (list2.count> 0) {Buffer4 = new byte [list2.count buffer3.Length]; list2.copyto (buffer4, 0); buffer3. CopyTo (buffer4, list2.Count); stream1 = new RequestStream (buffer4, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1.OriginalFileName);} else {stream1 = new RequestStream (Buffer3, Buffer1, Stream1.FileStream, Stream1.fstatus, Stream1.rstatus, Text3, Flag1, Application1.context, Stream1.RiginalFileName);} list1.addrange (stream1.readbody);

if (! text2 = string.Empty) {progress1.ReceivedLength = num1 buffer3.Length; progress1.FileName = stream1.OriginalFileName;. progress1.FileCount = ((Hashtable) application1.Context.Items [ "FileList"]) Count; if (flag1) {progress1.UploadStatus = Progress.UploadStatusEnum.Uploaded;} else {application1.Application.Remove ( "_ UploadGUID_" text2);}}} byte [] buffer5 = new byte [list1.Count]; list1.CopyTo (buffer5); this.populaterequestData (Request1, Buffer5);} catch (exception exception1) {this.clearapplication (application); throw exception1;} Http://krystalware.com/files/slickupload.zip But feels much easier to think

转载请注明原文地址:https://www.9cbs.com/read-89145.html

New Post(0)