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.
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);
} |
Hi Indhumathy,
Nice, works like a charm for the GetImage action dealing with custom parameters. Very much appreciated :)
John
- 3 Replies
- 3 Participants
- Marked answer
-
JA John Akermanis
- Oct 29, 2021 03:27 PM UTC
- Nov 2, 2021 05:31 AM UTC