javascriptc#model-view-controllerplupload

Plupload chunk size renaming file to Blob


I'm using Plupload in order to download file. The configuration we have is the folowing :

$("#uploadData").pluploadQueue({
        // General settings
        runtimes: 'html5,flash,silverlight,html4',
        url: serviceurl,

        // Maximum file size
        max_file_size: '50mb',

        chunk_size: '1mb',

        max_file_count: 50,

        unique_names: true,

        // Resize images on clientside if we can
        resize: {
            width: 200,
            height: 200,
            quality: 90,
            crop: true // crop to exact dimensions
        },

        // Specify what files to browse for
        filters: [
            { title: "Documents Excel", extensions: "xlsx" }
        ],

        init: {

            FilesAdded: function (up, files) {
                up.start();
            },

            UploadComplete: function (up, files) {
                if (up.total.uploaded == up.files.length) {
                    $(".plupload_buttons").css("display", "inline");
                    $(".plupload_upload_status").css("display", "inline");
                    up.init();
                }
            }
        },

The problem i have is when i upload a file that is bigger than 1MB, i don't receive the right name, instead i receive Blob for name. For exemple, the name of my file is "Test.xlsx" and the size is 2MB, i will receive, on the server side, "blob" for name and not Test.

Limitation, i'm not allowed to change the chuck size limitation on the client. How can i get the right name.

Thank for your help.

code used to receive the data on the server side :

[System.Web.Mvc.HttpPost]
        public ActionResult UploadData(int? chunk, string name)
        {
            var fileUpload = Request.Files[0];

            if (Session["upDataFiles"] == null)
            {
                Session["upDataFiles"] = new List<FileUploadViewModel>();
            }

            Session["upDataFiles"] = UpdateTempDataUpload(fileUpload.FileName, name, (List<FileUploadViewModel>)Session["upDataFiles"]);

            UploadFile(chunk, name);
            return Content("chunk uploaded", "text/plain");
        }

private void UploadFile(int? fileChunk, string fileName)
        {
            var fileUpload = Request.Files[0];
            var uploadPath = Server.MapPath("~/App_Data");
            var fullPath = Path.Combine(uploadPath, fileName);
            fileChunk = fileChunk ?? 0;
            using (var fs = new FileStream(Path.Combine(uploadPath, fileName), fileChunk == 0 ? FileMode.Create : FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
            {
                var buffer = new byte[fileUpload.InputStream.Length];
                fileUpload.InputStream.Read(buffer, 0, buffer.Length);
                fs.Write(buffer, 0, buffer.Length);
                fs.Close();
            }
        }

When i check the name in the request.File object, it's blob and not the actual name.


Solution

  • This issue was described in detail on GitHub. It might be a little confusing, but from what I understand: