How to Find out that a Upload of multiple Files is complete?

3 Answers 36 Views
Upload
Dominik
Top achievements
Rank 2
Iron
Dominik asked on 27 Jun 2022, 09:12 AM

<TelerikUpload SaveUrl="api/v1.0/files/save"
               RemoveUrl="api/v1.0/files/remove"
               AllowedExtensions="@AllowedFileTypes"
               MinFileSize="@MinFileSize"
               MaxFileSize="@MaxFileSize"
               AutoUpload="true"
               Multiple="true"
               WithCredentials="false"
               OnUpload="@OnUploadHandler"
               OnProgress="@OnProgressHandler"/>

I need an EventCallBack for "OnComplete" for a completion of all files or "OnProgress???" for all files. Or a complete different solution.

3 Answers, 1 is accepted

Sort by
0
Accepted
Dominik
Top achievements
Rank 2
Iron
answered on 27 Jun 2022, 03:33 PM
That's my solution for now. Maybe needs improvement for Error-Handling.
private int count = 0;

protected async Task OnUploadHandler(UploadEventArgs args)
{
   count = args.Files.Count;
}

protected void OnSuccessHandler(UploadSuccessEventArgs args)
{
   count -= args.Files.Count;
   if (count == 0)
   {
      OnUploadReady?.Invoke();
   }       
}

1
Timothy J
Top achievements
Rank 2
Bronze
Iron
Iron
answered on 27 Jun 2022, 02:11 PM
From the docs it appears OnSuccess fires for each file.  I think you need to keep track of each file via OnSelect and keep track of the count in both events and when the counts match, you can fire your own OnAllFileSuccess event.
0
Dominik
Top achievements
Rank 2
Iron
answered on 27 Jun 2022, 02:23 PM
I was afraid of it! Progress should improve it.
Tags
Upload
Asked by
Dominik
Top achievements
Rank 2
Iron
Answers by
Dominik
Top achievements
Rank 2
Iron
Timothy J
Top achievements
Rank 2
Bronze
Iron
Iron
Share this question
or