Custom Data

I am aware that custom data was added to Blazor FileManager and available for "FileOperations" and "Upload". However, custom data does not extend to the "Download" or "GetImage" controller action. 

There is a workaround for the "Download" controller action using the "beforeDownload" event to modify the payload then resubmit.

With "GetImage" there seems to be no way to send custom data even as a workaround.

I have a scenario where the root path has a fixed root (i.e. D:\\FixedRoot), but from a button on a grid row, I need to pass a dynamic subfolder to the FileManager controller which differs on each grid row (i.e. D:\\FixRoot\subFolderTarget"). Effectively, you are dynamically resetting the PhysicalFileProvider RootFolder. 

Is there some way to do the same with the controller "GetImage" action?

It would be nice if FileManager had a uniform way to pass custom data to all controller actions. That would solve a lot of custom scenarios. 


3 Replies 1 reply marked as answer

IL Indhumathy Loganathan Syncfusion Team November 1, 2021 12:14 PM UTC

Hi John, 
 
Greetings from Syncfusion support. 
 
We have validated your requirement in Blazor File Manager component. Currently we have support to send authorization header value from client to server in the OnSend event of File Manager for both Read and Upload operations. However, you can pass the custom value for Download operation by cancelling the default Download operation. 
 
We are unable to add the custom header in GetImage request since the GetImage is processed using query string parameter and download processed using form element.  
   
If we are going to use ajax (asynchronous request) then, each image creates individual request and its having certain time delay based on image size, network bandwidth and server respond time. We are unable to update the headers to the corresponding image tag value. So, it is not possible to implement these operations using Ajax requests.

It is not feasible to provide support to add custom header in GetImage request. However, we come up with a workaround to meet your requirement. You can append the custom value in the args.ImageUrl of each image file by using BeforeImageLoad event. Check the below code snippet.
 
 
[index.razor] 
 
    public void beforeImageLoad(BeforeImageLoadEventArgs<FileManagerDirectoryContent> args) 
    { 
        args.ImageUrl = args.ImageUrl + "&SubFolder=Pictures"; 
    } 
[FileManagerController.cs] 
 
    public class FileManagerDirectoryContentExtend : FileManagerDirectoryContent 
    { 
        public string SubFolder { get; set; } 
        public string customvalue { get; set; } 
    } 
    … 
// gets the image(s) from the given path 
[Route("GetImage")] 
public IActionResult GetImage(FileManagerDirectoryContentExtend args) 
{ 
    var val = args.SubFolder; 
    this.operation.RootFolder(this.basePath + "\\" + this.root + "\\" + val); 
    return this.operation.GetImage(args.Path, args.Id, false, null, null); 
} 
 
However, this way is not suitable to pass sensitive details such as username or password. Because this will be added with the image Url links and visible at DOM. Please find the sample demonstrating the solution from below link. 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Indhumathy L 


Marked as answer

JA John Akermanis November 1, 2021 07:23 PM UTC

Hi Indhumathy,

Nice, works like a charm for the GetImage action dealing with custom parameters. Very much appreciated :)

John



KR Keerthana Rajendran Syncfusion Team November 2, 2021 05:31 AM UTC

Hi John, 

Thanks for the update. We are glad to hear that the provided suggestions helped you. Please get back to us if you need any further assistance. 

Regards, 
Keerthana R. 


Loader.
Up arrow icon