Tuesday, May 13, 2014

Webpage for uploading really large files to your webserver

Background:
I have a website hobby project named GAC (for reasons not so obvious to anyone thats not me). Anyways, this website is hosted locally only on an old laptop of mine and it is connected to my TV and also an arduino board that drives a couple of SSR's for in-house light switching.
Showing GAC 1.5 in Chrome
One of the features of GAC is it's mediacenter controls. I would upload a file to the server using SMB on the LAN and the video files then got listed on the website, where i could then start playback on the TV directly from the browser. A handy feature that makes me start playback from any device in the house with a web browser.

Now i'm a C# guy and not much of a web developer, so when i started wandering over to the world of websites i choose the natural path of continuing to use Visual Studio and create websites with ASP.NET.

The problem:
This went great, up till GAC 1.4 when i added a file-upload feature. There is a file upload control in Visual Studio that you can use, but it has one hidden limitation, and it's a big one.
When you add a file to the FileUpload control and call SaveAs the runtime behind that will start buffering the file, so it has the whole file in RAM before it writes anything to disc. Now this is a reasonable aproach for small files as it lessens the disk load, but in my case it meant i would need to alocate many gigabytes of ram just for the file transfer.
I also hit some bogus limitation with web.config not letting me set the MaxRequestLength above ~4gb. And after spending hours on google and not really getting where i wanted i decided to simply ditch ASP.NET and implement some HTML5/PHP magic for this feature.


I went with Plupload, and you can download it here and also get examples and good documentation:
http://www.plupload.com/
I'm very happy with Plupload, it's providing easy and limit-free implementation, that work well with every browser and configuration i have tried.

And as always my project is available on GitHub, called GAC






No comments:

Post a Comment