Download large files (1 GB) -ASP.net

I need to upload large files of at least 1GB in size. I use ASP.Net , C# and IIS 5.1 as my development platform.

I use:

 HIF.PostedFile.InputStream.Read(fileBytes,0,HIF.PostedFile.ContentLength) 

before use:

 File.WriteAllBytes(filePath, fileByteArray) 

(does not go here, but gives a System.OutOfMemoryException exception)

I have httpRuntime installed httpRuntime in:

executeTimeout = " 999999 " maxRequestLength = " 2097151 " (it is 2GB!) useFullyQualifiedRedirectUrl = "true" minFreeThreads = "8" minLocalRequestFreeThreads = "4" appRequestQueueLimit = "5000" enableVersionHeader = "true" "true"

I also set maxAllowedContentLength="**2097151**" (I guess it only for IIS7)

I changed the IIS connection timeout to 999,999 seconds.

I can’t upload files even 4578KB (Ajaz-Uploader.zip)

+6
source share
8 answers

We have an application that sometimes needs to upload files of 1 and 2 GB in size, so it also works. After much research, I came to the conclusion that we need to implement the previously mentioned NeatUpload or something like that.

Also, keep in mind that

 <requestLimits maxAllowedContentLength=.../> 

measured in bytes , and

 <httpRuntime maxRequestLength=.../> 

measured in kilobytes . Therefore, your values ​​should look like this:

 <httpRuntime maxRequestLength="2097151"/> ... <requestLimits maxAllowedContentLength="2097151000"/> 
+5
source

I googled and found - NeatUpload


Another solution would be to read the bytes on the client and send it to the server, the server will save the file. Example

Server: in the namespace - Uploader, class - Upload

 [WebMethod] public bool Write(String fileName, Byte[] data) { FileStream fs = File.Open(fileName, FileMode.Open); BinaryWriter bw = new BinaryWriter(fs); bw.Write(data); bw.Close(); return true; } 

Client:

 string filename = "C:\..\file.abc"; Uploader.Upload up = new Uploader.Upload(); FileStream fs = File.Create(fileName); BinaryReader br = new BinaryReader(fs); // Read all the bytes Byte[] data = br.ReadBytes(); up.Write(filename,data); 
+3
source

I know this is an old question, but still not answered.

So here is what you need to do:

In the web.config file, add this to:

  <!-- 3GB Files / in kilobyte (3072*1024) --> <httpRuntime targetFramework="4.5" maxRequestLength="3145728"/> 

and it is under

 <security> <requestFiltering> <!-- 3GB Files / in byte (3072*1024*1024) --> <requestLimits maxAllowedContentLength="3221225472" /> </requestFiltering> </security> 

In the commentary, you see how this works. In one you need to have sie in bytes, and in the other in kilobytes. Hope this helps.

+1
source

Try copying without loading each item into memory:

 public void CopyFile() { Stream source = HIF.PostedFile.InputStream; //your source file Stream destination = File.OpenWrite(filePath); //your destination Copy(source, destination); } public static long Copy(Stream from, Stream to) { long copiedByteCount = 0; byte[] buffer = new byte[2 << 16]; for (int len; (len = from.Read(buffer, 0, buffer.Length)) > 0; ) { to.Write(buffer, 0, len); copiedByteCount += len; } to.Flush(); return copiedByteCount; } 
0
source

Check out this blog post about uploading large files. It also has several links to some discussion forums that may also shed light on this. It is intended to use a custom HttpHandler for this or a custom Flash / Silverlight control.

0
source

For IIS 6.0, you can change AspMaxEntityAllowed in Metabase.xml, but I don't find this straightforward in IIS 5.1.

This link may help, hope this happens:

http://itonlinesolutions.com/phpbb3/viewtopic.php?f=3&t=63

0
source

The maxRequestLength setting should be sufficient to download files larger than 4 MB, which is the default limit for the size of the HTTP request. Please make sure that nothing cancels your configuration file.

Alternatively, you can check the asynchronous download provided by Telerik , which downloads files using 2 MB blocks and can effectively bypass the ASP.NET request size limit.

0
source

I think you should use Response.TransmitFile, this method does not load the file into the web server memory, it transfers the file without using the resources of the web server.

 if (Controller.ValidateFileExist()) { ClearFields(); Response.Clear(); Response.ContentType = "text/plain"; Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", "FileNAme.Ext")); Response.TransmitFile(FileNAme.Ext); Response.End(); Controller.DeleteFile(); } 
-one
source

All Articles