Wie lade ich große Dateien mit MVC 4 hoch?

Ich hatte es funktioniert .. aber ich bemerkte, sobald die Dateien, die ich hochlud, größer wurden (ca. 4000k), würde der Controller nicht aufgerufen werden ..

Also habe ich in Chunking hinzugefügt, was dieses Problem behoben hat. Aber jetzt, wenn ich die Datei öffne, ist sie voller Müllzeichen.

Was ist also der richtige Weg, um große Dateien mit plupload / MVC 4 hochzuladen?

Hier ist mein aktueller Code

  $(document).ready(function () {

    var uploader = new plupload.Uploader({
        runtimes: 'html5',
        browse_button: 'pickfiles',
        container: 'container',
     //   max_file_size: '20000mb',
        url: '@Url.Action("Upload", "Home")',
        chunk_size: '4mb',
        //filters: [
        //    { title: "Excel files", extensions: "xls,xlsx" },
        //    { title: "Text files", extensions: "txt" }
        //],
        multiple_queues: true,
        multipart: true,
        multipart_params: { taskId: '' }
    });

und der Controller

  [HttpPost]
    public ActionResult Upload(int? chunk, string name, string taskId)
    {
        string filePath = "";
        var fileUpload = Request.Files[0];
        var uploadPath = Server.MapPath("~/App_Data/Uploads");
        chunk = chunk ?? 0;
        string uploadedFilePath = Path.Combine(uploadPath, name);
        var fileName = Path.GetFileName(uploadedFilePath);

 try
        {
            using (var fs = new FileStream(filePath, chunk == 0 ? FileMode.Create : FileMode.Append))
            {
                var buffer = new byte[fileUpload.InputStream.Length];
                fileUpload.InputStream.Read(buffer, 0, buffer.Length);
                fs.Write(buffer, 0, buffer.Length);
            }

            //Log to DB for future processing
            InstanceExpert.AddProcessStart(filePath, Int32.Parse(taskId));
        }

Antworten auf die Frage(3)

Ihre Antwort auf die Frage