Mitesh Machhi

Mitesh Machhi

  • 1.5k
  • 214
  • 275

Not able to generate public URL of specific folder using MegaAPIClient

May 24 2024 2:49 AM

When trying to generate the public url of any folder using MegaApiClient then API taking too longer time and not responding anything.

Is there any settings needed to be done before this ? As i am able to generate the link from Mega.IO UI

// Initialize MegaApiClient
var client = new MegaApiClient();

try
{
    client.Login(email, password);   
    var rootNode = await client.GetNodesAsync();   
    var seasonFolder = rootNode.FirstOrDefault(n => n.Type == NodeType.Directory && n.Name == eventSeason);   
    var eventFolder = await client.GetNodesAsync(seasonFolder);   
    var studioFolder = client.GetNodes(eventFolder.Where(x=>x.Name == eventName).FirstOrDefault());
    List<(string FileName, string Url, string ThumbnailUrl, string DownloadUrl, bool isFolder)> lstStudioFolder = new List<(string FileName, string Url, string ThumbnailUrl, string DownloadUrl, bool isFolder)>();
    foreach (var tmpStudio in studioFolder)
    {
        // Generate a public link for the folder
        var publicLink = client.GetDownloadLink(tmpStudio);
        lstStudioFolder.Add((tmpStudio.Name, publicLink.AbsoluteUri, string.Empty, string.Empty, true));
    }
    return View(lstStudioFolder);
}
finally
{
    await client.LogoutAsync();
}

 


Answers (2)