CancelAsync Does Not Appear to Remove File

Hello,


I have the following Razor file:


```

@implements IAsyncDisposable


<Syncfusion.Blazor.Inputs.SfUploader @ref="_subject" ID="files" AllowMultiple="false">

 <Syncfusion.Blazor.Inputs.UploaderEvents

        FileSelected="@OnSelected"

    />

   ...

</Syncfusion.Blazor.Inputs.SfUploader>


@code

{

    SfUploader? _subject = default!;

    FileInfo? Current { get; set; }


async Task OnSelected(SelectedEventArgs parameter)

    {

        switch (parameter.FilesData.Count)

        {

            case 0:

                break;

            case 1:

                Current = parameter.FilesData.Single();

                ...

                break;

            default:

                throw MultipleFilesDetectedException.Default;

        }

    }


   public ValueTask DisposeAsync()

    {

        return _subject?.CancelAsync(Current?.Yield().ToArray() ?? Empty.Array<FileInfo>()).ToOperation() ?? ValueTask.CompletedTask;

    }

}

```


In particular, the DisposeAsync call, where I check if a file is in progress and, if so, Cancel it.  The documentation states that this will remove files, but that does not be the case for me.  The remove URL is never called and the file remains on the server.

Is there another setting/call I should be using?  I did try calling RemoveAsync explicitly but that didn't do anything either.

Thank you for any assistance/guidance you can provide.


16 Replies

UD UdhayaKumar Duraisamy Syncfusion Team September 4, 2022 05:27 AM UTC

Hi Mike,


The CancelAsync Stops the in-progress chunked upload based on the file data. When the file upload is canceled, the partially uploaded file is removed from the server. Please refer to the below-shared documentation for more details.


Documentation : https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Inputs.SfUploader.html#Syncfusion_Blazor_Inputs_SfUploader_CancelAsync_Syncfusion_Blazor_Inputs_FileInfo


@using Syncfusion.Blazor.Inputs

 

<SfUploader MaxFileSize=104857600 @ref="_subject" ID="files" AllowMultiple="false">

    <UploaderAsyncSettings SaveUrl=https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save

                           RemoveUrl=https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove

                           ChunkSize=500000></UploaderAsyncSettings>

    <UploaderEvents FileSelected="@OnSelected"></UploaderEvents>

</SfUploader>

 

<button @onclick="@cancelAsyncHandler">Cancel</button>

 

@code

{

 

    SfUploader _subject = default!;

 

    FileInfo Current { get; set; }

 

    public async Task cancelAsyncHandler()

    {

        await _subject.CancelAsync();

    }

 

    async Task OnSelected(SelectedEventArgs parameter)

    {

 

    }

}


Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorUploader-427882195


Kindly try the above sample and let us know if this meets your requirement. If we misunderstood the requirement, we request you to provide additional details about the requirement as mentioned below. This will help us validate the requirement further and provide you with a better solution.

  1. Exact Requirement details.
  2. Please modify the shared sample as per your scenario.


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Regards,

Udhaya Kumar D




MI Mike-E September 4, 2022 08:56 AM UTC

Hi Udhaya,

Thank you for your reply.  Can you confirm that the file gets removed during DisposeAsync?  That seems to be the difference between your provided sample and mine and I am wondering if that is why Remove is not being called in my case.

Thank you for any continued assistance you can provide,

Michael



UD UdhayaKumar Duraisamy Syncfusion Team September 5, 2022 01:48 PM UTC

Hi Mike,


We request you to provide additional details about the query as mentioned below, This will help us validate the query further and provide you with a better solution.


1. Are you facing the issue in any particular scenario?

2. Is the File Upload component rendered within any other component or alone?

3. Issue reproducing runnable sample (or modify the previously shared sample).

4. Issue replication steps.

5. Video illustration of the issue.


Regards,

Udhaya Kumar D




MI Mike-E September 6, 2022 11:49 AM UTC

Hi @Udhaya,

Thank you for your patience in tracking this down with me. As it seems the solution that was provided demonstrates this issue not occurring, I took a look into it. However, it appears that the upload/remove URL are not local to the project:



Do you have a solution that references the local project for upload/remove? I can better track this down if so.


To be certain, the problem I am facing is not the `OnRemove` event handler getting called, but the server call to remove the file is not getting called on `CancelAsync`.


Thank you,

Michael



MM Mohanraj Mathaiyan Syncfusion Team September 7, 2022 04:12 PM UTC

Hi Mike,

We are validating the requirement. We will update the further details in two business days (9th September 2022)

Regards,

Mohanraj M




MI Mike-E September 7, 2022 04:24 PM UTC

Thank you for the update, Mohanraj.  If it helps I am slammed here, too :D



UD UdhayaKumar Duraisamy Syncfusion Team September 12, 2022 04:35 PM UTC

Hi Mike,


Sorry for the inconvenience caused.


Due to complexity, We are still validating the requirement. We will update the further details in two business days (14th September 2022).


Regards,

Udhaya Kumar D



MI Mike-E September 12, 2022 05:08 PM UTC

Hi Udhaya, thank you for the update.  No worries on this side.  Please take your time.


Thank you,

Michael



UD UdhayaKumar Duraisamy Syncfusion Team September 13, 2022 09:53 AM UTC

Hi Mike,


We have considered the reported issue as a bug from our end and will be fixed in our September 21st patch release. You can track the status of the issue by the below feedback link.


Feedback Link :  https://www.syncfusion.com/feedback/37456/filedata-not-received-at-server-endpoint-in-remove-method


Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”


Regards,

Udhaya Kumar D



MI Mike-E September 13, 2022 10:04 AM UTC

Woohoo!  Thank you very much Udhaya and team that is good news.  Your excellent service and support are appreciated!



UD UdhayaKumar Duraisamy Syncfusion Team September 14, 2022 08:35 AM UTC

Hi Mike,


Thanks for your appreciation. As we mentioned earlier we will include the fix for the issue in our September 21st patch release.


Regards,

Udhaya Kumar D



YS Yohapuja Selvakumaran Syncfusion Team September 22, 2022 08:29 AM UTC

Hi Mike,


Due to complexity we couldn’t include the fix for the issue “Filedata not received at server endpoint in Remove method”. We will include the fix in our upcoming Volume 3 Main release which is expected to be rolled out on the end of September 2022. We appreciate your patience until then.


Regard,

Yohapuja S



MI Mike-E September 22, 2022 04:30 PM UTC

No worries Yohapuja.  I appreciate the update and your efforts out there.



UD UdhayaKumar Duraisamy Syncfusion Team October 2, 2022 05:02 AM UTC

Hi Mike,


We have fixed the reported issue and the fix in the testing phase, we will include the 12th October 2022 weekly patch release.


Regards,

Udhaya Kumar D



MI Mike-E October 2, 2022 09:52 AM UTC

Woohoo!  That is good news.  Thank you for your efforts out there Udhaya and team!



UD UdhayaKumar Duraisamy Syncfusion Team October 12, 2022 05:08 AM UTC

Hi Mike,


We have fixed your reported issue from our end in the latest 20.2.50 version. So, we suggest you upgrade to our latest version to resolve the current issue.

Please find the release notes here: https://blazor.syncfusion.com/documentation/release-notes/20.2.50?type=all#uploader


Regards,

Udhaya Kumar D


Loader.
Up arrow icon