This is a migrated thread and some comments may be shown as answers.

Upload fires Complete and Success on each file uploaded in chunks

1 Answer 284 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 06 Feb 2020, 12:24 AM

Hi, 

I followed the implementation and documentation for the upload here https://demos.telerik.com/aspnet-mvc/upload/events and it looks like the complete event should fire once when all files are uploaded.  It does in your demo, but you are not using .ChunkSize 

I am using the .ChunkSize and with that implementation, it fires a complete and success on each file.  I expect the success to fire on each file but not the complete.  I'm looking for some event to fire once all files are uploaded so I can process them server side. if this isn't the right implementation please suggest a way to accomplish that. 

 

Here is code that generates n complete alerts where n is the number of files uploaded successfully:

Razor view:

<div>
    @(Html.Kendo().Upload()
        .Name("files")
        .Async(a => a
            .Save("Chunk_Upload_Save", "Home")
            .ChunkSize(110000)
            .AutoUpload(false)
        )
        .Events(events => events
            .Complete("onComplete")
        )
    )
</div>
<script>
    function onComplete(e) {
        alert("Complete:");
    }
</script>

 

Controller:

  public ActionResult Chunk_Upload_Save(IEnumerable<HttpPostedFileBase> files, string metaData)
        {
            try
            {
                var ms = new MemoryStream(Encoding.UTF8.GetBytes(metaData));
                var serializer = new DataContractJsonSerializer(typeof(ChunkMetaData));
                var chunkData = (ChunkMetaData)serializer.ReadObject(ms);
                ms.Close();

    
                return Json(new FileResult
                {
                    uploaded = chunkData.TotalChunks - 1 <= chunkData.ChunkIndex,
                    fileUid = chunkData.UploadUid
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 07 Feb 2020, 12:55 PM

Hello Dave,

Thank you for reporting the behavior.

You will find my reply in the private thread you opened. I am sharing it here too so that other possible members that are affected would find the information. The reported behavior is a bug in the current implementation of the Upload. It could be follow on this link to our Feedback Portal.

Regards,
Martin
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
Upload
Asked by
Dave
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or