Large File uploading to asp.net MVC
Asked Answered
S

4

20

I need a way to upload large files (600 mb to 4 gb) in an asp.net mvc website. Currently I am using swfupload; it works well enough, but it is a huge hit on the webserver because it sends it in one big upload, plus I have to set it in the web.config to allow that huge of a file, which is a huge security risk. In the past when I was doing web forms development I used Neatupload which breaks up the file into chunks and uploads them individually. I am looking for a way to upload large files in mvc that uploads via chunking it up. Any ideas on how I could do this?

Sawdust answered 28/3, 2009 at 4:15 Comment(0)
H
8

Silverlight File Upload

Hostess answered 19/4, 2009 at 13:4 Comment(1)
Just so anyone visiting this knows. I took this modified it some and use it now. swfupload was giving me too many problems once the files got above 1GBSawdust
S
7

I ended up using Darren Johnstone's ASP.NET File Upload Module to handle the uploading on the server side. Though I modified it slightly so that it could take a guid on the querystring that it would save the temp file to that guid name.

It was nice because it saved the file as it arrived at the server, and stripped the file out of the posted data which it then sends to the action on the controller that was specified.

Sawdust answered 20/4, 2009 at 20:0 Comment(2)
How did you get it to work in ASP.NET MVC without the runat=server controls? Are there punch-in points in the remaining classes? Would you mind sharing a code sample?Masteratarms
The upload module contains 2 pieces, the first is a httphandler that when a file is posted (using mime encoding) it strips the file out saving directly as it goes and then letting whatever page/controller was called then be called, just with the files[] array empty. The second part is the controls used for standard asp.net forms. I didn't use those controls at all. Instead I used the swfupload that I linked in the original question, that uses js and flash to upload a file. I then had a action call "UploadAsync" on a controller that the swfupload was configured to post to.Sawdust
S
2

Example in my view:

<input id="FileGUID" name="FileGUID" type="hidden" value="f632c00b-9b66-4716-8075-79df63b780fb" />
    <input type="file" id="FileUpload1" name="fileUpload1" />

    <script type="text/javascript">
        var UploadUrl = '/Video/AsyncUpload?FileGUID=f632c00b-9b66-4716-8075-79df63b780fb';
        $(function() {
            $("#FileUpload1").makeAsyncUploader({
                upload_url: UploadUrl,
                flash_url: '/Content/Flash/swfupload.swf',
                button_image_url: '/Content/Images/blank-button.png',
                button_text: '<font face="Helvetica, Arial" size="13pt" color="#ffffff">Upload File</font>',
                disableDuringUpload: 'input[type="submit"]',
                file_size_limit: '8024 MB',
                button_text_top_padding: 2
            });
        });
    </script>

Then in the actual save action for this page I look for a file where the asyncupload action would have saved the file based on the FileGUID

Sawdust answered 18/9, 2009 at 16:16 Comment(0)
P
1

A SignalR implementation example can be found here.

This also includes functionality for working with HttpContext.Request.GetBufferlessInputStream(), which allows you to begin working with the post data before it's fully uploaded.

Porky answered 9/3, 2013 at 1:22 Comment(2)
The link you provided is dead.Knowling
I've replaced the linkPorky

© 2022 - 2024 — McMap. All rights reserved.