Is there a way to get the time it took to upload a file programmatically

Using the blazor SfUploader is there a way to get the amount of time it took to upload a file programmatically.




3 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team September 28, 2020 04:24 PM UTC

Hi ScottAtScorpios, 

Greetings from Syncfusion support. 

As per your requirement, we have prepared sample for your reference. You can start the time in BeforeUplaod event and stop in Success event and displayed in milliseconds. Please find the test sample and code snippet below for reference. 

<div>Time for Uploading file: @actiontime ms</div> 
 
<SfUploader ID="UploadFiles"> 
    <UploaderAsyncSettings SaveUrl="https://ej2.syncfusion.com/services/api/uploadbox/Save" RemoveUrl="https://ej2.syncfusion.com/services/api/uploadbox/Remove"> 
    </UploaderAsyncSettings> 
    <UploaderEvents BeforeUpload="onBeforeUpload" Success="UploadedSuccuessfully"></UploaderEvents> 
</SfUploader> 
 
@code { 
    [Inject] 
    protected IJSRuntime JsRuntime { get; set; } 
    internal Stopwatch timer = new Stopwatch(); 
    internal string actiontime { get; set; } 
    public void onBeforeUpload(BeforeUploadEventArgs args) 
    { 
        timer.Restart(); 
    } 
    public void UploadedSuccuessfully(SuccessEventArgs args) 
    { 
        timer.Stop(); 
        actiontime = timer.ElapsedMilliseconds.ToString(); 
    } 
} 

 

Kindly check with the above sample. Please get back us if you need further assistance. 

Regards, 
Ponmani M 


Marked as answer

SC ScottAtScorpios September 28, 2020 09:05 PM UTC

Using your uploader events I was able to get my code working. Thank You.


PM Ponmani Murugaiyan Syncfusion Team September 29, 2020 04:18 AM UTC

Hi ScottAtScorpios, 

Thanks for the update. 

We are glad to hear that the provided suggestion helps you in achieving your requirement. Please get back us f you need further assistance. 

Regards, 
Ponmani M 


Loader.
Up arrow icon