Are you open for JavaScript? If in this case, try this jQuery plugin, which allows you to load massive data (lots of GB). It downloads files using the HTML5 FileReader API functions and Silverlight reserve if the browser does not have support providing a mechanism based on sending and receiving TCP / IP packets with the corresponding ACK. Files are uploaded in pieces by size (4 MB by default).
Plus: it also has a file queue mode.
Here is an example of how you can use it in a Razor view:
$(function () { var file = $("#file").createUploaderHtml5({ postDataUrl: "@Url.Action("Upload", "Home")", packetSize: 4 * 1024 * 1024, onPreparingUpload: function (plugin, ufname, umime, usize) { plugin.settings.logger("ufname = [" + ufname + "] umime = [" + umime + "] usize = [" + usize + "]"); return true; }, onInitPacketArrived: function (plugin, guid) { plugin.settings.logger("guid = [" + guid + "]"); }, onDataPacketArrived: function (plugin, ack, total) { //plugin.settings.logger("ACK [" + ack.Guid + "] packet = [" + ack.Packet + "] total = [" + total + "]"); var percent = Math.round(ack.Packet / total * 100); $("#progressbar").attr("value", percent); $("#percent").html(percent + " %"); }, onFileUploaded: function (pl) { pl.settings.logger("File finished!!!"); }, logger: function(msg) { var lg = $("#logger"); lg.html(lg.html() + msg + "<br />"); } }); $("#start").click(function () { file.startUpload(); }); $("#stop").click(function () { file.cancelUpload(); }); });
Here is the action code to download:
[HttpPost] public ActionResult Upload(FormCollection collection) { var packetSize = 4 * 1024 * 1024; // default to 4 MB var filePath = Server.MapPath("~/_temp_upload/"); var result = UploadHelper.ProcessRequest(Request, filePath, packetSize); if (result != null) { var metadata = UploadHelper.GetMetadataInfo(filePath, result.Guid); // do anything with the metadata } if (result != null) return Json(result); return Content(""); }
nebtrx
source share