Hi all,
We created a method to download media folder as zip. To use this, we added a Download surface controller with an action, so simply this url is enough to download the folder: /download/downloadaszip?id={nodeid}
Now I would like to add an action to the media section, so a user could simply click Download as zip and the download url is called.
I already created a component to add the action, this is quite simple, but I cannot get the url to work.
I now have this code:
// the event listener method:
void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
{
// this will add a custom menu item for all admin users
// for all media tree nodes
if (sender.TreeAlias == "media"
&& sender.Security.CurrentUser.Groups.Any(x => x.Alias.InvariantEquals("admin")))
{
// creates a menu action that will open /umbraco/currentSection/itemAlias.html
var i = new Umbraco.Web.Models.Trees.MenuItem("downloadMediaAsZip", "Download als zip");
i.AdditionalData.Add("actionUrl", $"/download/FolderAsZip?id={e.NodeId})");
// sets the icon to icon-wine-glass
i.Icon = "download-alt";
// insert at index 5
e.Menu.Items.Insert(5, i);
}
}
Could anyone give advice in how I could get this url called when clicking the action?
Thank you!