I'd like to create my own functions for some file types when the user attempts to open or double click. Where do in the standard template is the code to intercept that user request? I looked through the FileManagerController and PhysicalFileProvider class modules but didn't see an "Open"
|
@using System.Text;
@using Syncfusion.Blazor.FileManager;
<div class="control-section">
<SfFileManager TValue="FileManagerDirectoryContent">
<FileManagerEvents TValue="FileManagerDirectoryContent" OnMenuClick="MenuClick" OnFileOpen="Open"></FileManagerEvents>
<FileManagerAjaxSettings Url="/api/FileManager/FileOperations"
UploadUrl="/api/FileManager/Upload"
DownloadUrl="/api/FileManager/Download"
GetImageUrl="/api/FileManager/GetImage">
</FileManagerAjaxSettings>
</SfFileManager>
</div>
@code{
private async Task MenuClick(MenuClickEventArgs<FileManagerDirectoryContent> args)
{
if (args.Item.Text == "Open" && args.FileDetails[0].IsFile)
{
await CustomCall(); // perform any custom operation here after restricting default open
}
}
private async Task Open(FileOpenEventArgs<FileManagerDirectoryContent> args)
{
if (args.FileDetails.IsFile)
{
await CustomCall(); // you can perform any custom operation requried from your end here
}
}
public class CustomData
{
public string Action { get; set; }
}
private async Task CustomCall()
{
HttpClient clientInstance = new HttpClient();
// any custom data to be passed to the function can be added here CustomData requestData = new CustomData
{
Action = "custom"
};
string stringPayload = await Task.Run(() => System.Text.Json.JsonSerializer.Serialize(requestData));
using HttpContent httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/json");
HttpResponseMessage httpResponse = await clientInstance.PostAsync(new Uri(https://localhost:44365/api/FileManager/Custom), httpContent);
}
} |