We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Override delete and upload methods only on currect razor page

I have multiple razor pages that correspond to different folders(All files, favourites, Recents and Trashcan) and each file manager in these pages has its root folder set to the corresponding folder of the page. I need to override the delete method so I can move the file to the Trashcan before it is permanently deleted, but I need it to be overridden in every page except the Trashcan. Also I need to override the upload method so I can copy the file to Recents when it is uploaded. Can you provide any support?


3 Replies

SA SureshRajan Alagarsamy Syncfusion Team March 20, 2023 04:01 PM UTC

Hi Lyubo,


We have reviewed your shared details and understand that you want to override the delete and upload operation.


Query 1 : To override the delete operation.


We suggest you use the “OnSend” event and cancel the action by setting the cancel argument as true if the action is delete. This will cancel the delete operation, and you can implement your code to achieve your requirement.


Query 2 : To override the upload operation.


We suggest using the “OnSend” event and cancel the action by setting the cancel argument as true if the action is upload. This will cancel the upload operation, and you can implement your code to achieve your requirement.


We recommend referring to our API properties for more details on the “BeforeSendEventArgs” class. Refer to the below attached link.


API properties: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.FileManager.BeforeSendEventArgs.html#properties


Refer to the below code snippet for further reference.


Code Snippet :


[Index.razor]

 

<SfFileManager TValue="FileManagerDirectoryContent" @ref="filemanager">

    <FileManagerAjaxSettings Url=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/FileOperations

                             UploadUrl=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Upload

                             DownloadUrl=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/Download

                             GetImageUrl=https://ej2-aspcore-service.azurewebsites.net/api/FileManager/GetImage>

    </FileManagerAjaxSettings>

    <FileManagerEvents TValue="FileManagerDirectoryContent" OnSend="OnSend"></FileManagerEvents>

</SfFileManager>

 

@code{

  public SfFileManager<FileManagerDirectoryContent> filemanager;

 

  //OnSend Event definition

  public void OnSend(BeforeSendEventArgs args)

  {

      //For override delete operation

      if(args.Action == "delete")

      {

          // TO cancel the delete operation

          args.Cancel = true;

          //Manually triggering delete operation

          filemanager.DeleteFilesAsync(new string[] {"Downloads"});

      }

      else if(args.Action == "upload")

      {

          // To cancel the upload operation

          args.Cancel = true;

          // Call the UploadFilesAsync method to upload the files manually.

          filemanager.UploadFilesAsync();

      }

  }

}

 


Check out the shared details and get back to us if you need any further assistance.


Regards,
Suresh.


Attachment: FileManager_ec3103fb.zip


LY Lyubo March 25, 2023 06:05 PM UTC

The sample works for delete but not for upload. 



SA SureshRajan Alagarsamy Syncfusion Team March 30, 2023 04:00 PM UTC

Hi Lyubo,


From your shared details, We understand that you are facing issue with UploadFilesAsync method in File Manager component. We can reproduce your reported issue, and we have considered it a bug from our end. The fix for this issue will be included in our upcoming patch release on April 11, 2023.


Feedback : https://www.syncfusion.com/feedback/42548/uploadfilesasync-method-doesnt-working-properly-for-onsend-event-in-the-file


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.


Check out the shared details and get back to us if you need any further assistance.


Regards,
Suresh.


Loader.
Up arrow icon