Git Product home page Git Product logo

Comments (4)

gpailler avatar gpailler commented on August 13, 2024

Hello,

I'm not able to reproduce the issue you described with the following test

[Theory]
[InlineData("https://mega.nz/file/B7BnxarD#pt_9ebHpGvzCi3LBVVfBcudIys7mZGma_wHHquWTEkE")]
public async void GetNodeFromLinkAsync_Succeeds(string fileLink)
{
  var instance = new MegaApiClient();
  await instance.LoginAnonymousAsync();
  var node = await instance.GetNodeFromLinkAsync(new Uri(fileLink));

  Assert.NotNull(node);
  Assert.Equal("fm.png", node.Name);
  Assert.Equal(597194, node. Size);
}

Could you provide a small sample?

from megaapiclient.

adeyblue avatar adeyblue commented on August 13, 2024

It happens when querying a just created folder now. The created folder shows up as 'undecrypted folder' in the web file manager

using System;
using System.Collections.Generic;
using CG.Web.MegaApiClient;

namespace ConsoleApp1
{
    class Program
    {
        static INode GetRootNode(MegaApiClient client)
        {
            IEnumerable<INode> newNodes = client.GetNodes();
            INode rootNode = null;
            foreach (INode node in newNodes)
            {
                if (node.Type == NodeType.Root)
                {
                    rootNode = node;
                    break;
                }
            }
            return rootNode;
        }

        static void Main(string[] args)
        {
            MegaApiClient client = new MegaApiClient();
            try
            {
                MegaApiClient.LogonSessionToken token = client.Login("email", "pass");
                Console.WriteLine("Logged in on session {0}", token.SessionId);
                INode rootNode = GetRootNode(client);
                string upFile = args[0];
                INode testFolder = client.CreateFolder("testFolder", rootNode);
                Console.WriteLine("Created {0}, type {1}, size {2}, id {3}", testFolder.Name, testFolder.Type, testFolder.Size, testFolder.Id);
                Console.WriteLine("Getting link");
                Uri link = client.GetDownloadLink(testFolder);
                Console.WriteLine("Got link {0}", link);
                INode newFolderNode = client.GetNodeFromLink(link);
                Console.WriteLine("Got node {0}, type {1}, size {2}, id {3}", newFolderNode.Name, newFolderNode.Type, newFolderNode.Size, newFolderNode.Id);
            }
            catch(Exception e)
            {
                Console.WriteLine("Caught exception type {0}: ({1}){2}{3}", e.GetType().Name, e.Message, Environment.NewLine, e.StackTrace);
            }
            client.Logout();
        }
    }
}

Logged in on session f_vJfH_...
Created testFolder, type Directory, size 0, id P9xj2CDZ
Getting link
Got link https://mega.nz/folder/bt5gGCSS#NNIYUaTjxQom2jvgzJgGeA
Caught exception type ApiException: (API response: AccessDenied)
at CG.Web.MegaApiClient.MegaApiClient.RequestCore[TResponse](RequestBase request, Byte[] key) in //MegaApiClient/MegaApiClient.cs:line 1136
at CG.Web.MegaApiClient.MegaApiClient.Request[TResponse](RequestBase request, Byte[] key) in /
/MegaApiClient/MegaApiClient.cs:line 1092
at CG.Web.MegaApiClient.MegaApiClient.GetNodeFromLink(Uri uri) in /_/MegaApiClient/MegaApiClient.cs:line 672
at ConsoleApp1.Program.Main(String[] args) in T:\nettest\ConsoleApp1\Program.cs:line 38

from megaapiclient.

gpailler avatar gpailler commented on August 13, 2024

The link references a folder so you should use GetNodeSFromLink() method instead.
I will update the library to throw a meaningful exception when GetNode(s)FromLink are called with incorrect url

from megaapiclient.

adeyblue avatar adeyblue commented on August 13, 2024

Thanks, still having problems though.
This code with this link
https://mega.nz/folder/L1xlRRAL#I5Lq0N5aUBT4dyLgp0QPFg
shows

Logged in on session Saz...
Got node Attribute deserialization failed: Unexpected character encountered while parsing value: ?. Path '', line 0, position 0., type Root, size 0, id O8AWGJBa

Got node Attribute deserialization failed: Unexpected character encountered while parsing value: (. Path '', line 0, position 0., type File, size 507568, id 68BWELLS

Both the file and folder are named AMlNVS0u1Co0STJw0CrOyHBTSMtLUcvPLHDML1fwVE9LUVYsMFUwydNNSwgoSAIL.
Trying to access the link via web browser shows 'Invalid decryption key' but that's the link that was generated by GetDownloadLink and is the one Mega shows.
link

using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Text;
using CG.Web.MegaApiClient;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            MegaApiClient client = new MegaApiClient();
            try
            {
                MegaApiClient.LogonSessionToken token = client.Login("mail", "pass");
                Console.WriteLine("Logged in on session {0}", token.SessionId);
                Uri link = new Uri(args[0]);
                IEnumerable<INode> newFolderNodes = client.GetNodesFromLink(link);
                foreach (INode dlNode in newFolderNodes)
                {
                    Console.WriteLine("Got node {0}, type {1}, size {2}, id {3}", dlNode.Name, dlNode.Type, dlNode.Size, dlNode.Id);
                }
            }
            catch(Exception e)
            {
                Console.WriteLine("Caught exception type {0}: ({1}){2}{3}", e.GetType().Name, e.Message, Environment.NewLine, e.StackTrace);
            }
            client.Logout();
        }
    }
}

from megaapiclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.