How to download a 100 MB file?

I am developing a File Server application in ASP.NET. I have to upload a 100 MB file and then save it to the SQL Server 2008 database in varbinary(max) . It is necessary to save the file in the database. I am using the FileUpload control. Please suggest me how to handle such a large file?
UPDATE
Any code sample would be great help, any code sample?
How to read a file in chunks?

+4
source share
6 answers

You can change the default limit (4 MB) for the directory and its children by dropping the special web.config in this directory. Thus, you don’t need to make the whole site valid for huge downloads (this may open you certain types of attacks).

Here is an example from a production application. This parameter is set for 200mb:

 <?xml version="1.0"?> <!-- Nested this web.config here to allow for huge uploads (up to 200mb) --> <configuration> <system.web> <httpRuntime maxRequestLength="200000"/> </system.web> </configuration> 

Nesting web.configs has no negative side effects - your existing web.config settings will still work on all sites, and these httpRuntime parameters will be inherited from this directory to down.

On the page that handles the download, make sure you have a higher than usual ScriptTimeout. This is measured in seconds:

 Server.ScriptTimeout = 1200; 

I like to set this on the page, not web.config, because it isolates the increased timeout down to this page.

On the SQL side, varbinary columns can have up to two gigs, so you can go there.

Update: I used this approach with 50+ mega files, but it is possible that in 100 megacenters standard methods may break. There are many third-party controls available that can take over from there, but I would probably look at Telerik RadUpload, as they are a quality name and look very polished: RadUpload

Regarding your update regarding reading a file in chunks, if you really want to write it, Bobby D pointed to this article: Downloading large files using HttpModule

+8
source

Try the following: Uploading large files to ASP.NET .

Let me know if this helps.

+3
source

ASP.NET has a default limit of 4 MB for file downloads. This article describes how to change this default and discusses some problems downloading large files.

+3
source

Since you are using SQL Server 2008 with a maximum value of 2gb for varbinary columns, you should be fine. Any regular script loading is likely to work. When you boot into this size, although basic HTTP or TCP / IP connections can be a problem, you really can't do anything about it.

+1
source

Break it into parts, assign a serial number for each part, after receiving the file on the server side (provided that there is a database), collect, sort the parts in accordance with the serial number and join them, deleting the serial numbers, I hope you do not get time out if this is the only problem! You could probably use TPL to load multiple parts and reunite with them the same!

+1
source

All Articles