Coder Social home page Coder Social logo

Create Folder about sdk HOT 14 CLOSED

meganz avatar meganz commented on September 13, 2024
Create Folder

from sdk.

Comments (14)

sergiohs84 avatar sergiohs84 commented on September 13, 2024

Hi Dmitry

You may want to have a look to the examples in the folder: sdk/examples.

Also, I suggest to generate the documentation related to the MegaApi (make doc), where you will find the details about every function, like void MegaApi::createFolder(name, parent, listener).

Regards

from sdk.

dima72 avatar dima72 commented on September 13, 2024

thank you for the hint my fried. It works like this:
SynchronousRequestListener listener;
megaApi->createFolder(folder_name.c_str(), ParentNode, &listener);

the ParentNode must be gotten before createFolder

from sdk.

sergiohs84 avatar sergiohs84 commented on September 13, 2024

Indeed. The parent node is the reference where the new folder will be created, so it must exists and it must be a valid pointer to a MegaNode.

Note you can use MegaNode* MegaApi::getRootNode() to get a pointer to the root of the cloud tree.

from sdk.

dima72 avatar dima72 commented on September 13, 2024

Dear Sergiosh,
is it necessary to delete/free node after it was obtained by getRoodNode and similar methods?
or MegaApi takes care of that?

from sdk.

sergiohs84 avatar sergiohs84 commented on September 13, 2024

Hi Dmitry

Please, review the documentation of the MegaApi interface. It states that "You take the ownership of the returned value", meaning that you are responsible for the object and you should delete it whenever it is not necessary any longer.

Most of the objects returned by similar methods works the same way, so you should free the allocated memory.

from sdk.

dima72 avatar dima72 commented on September 13, 2024

I see,
thanks.

from sdk.

dima72 avatar dima72 commented on September 13, 2024

sergiosh,

can you please suggest the way of using MegaNodes in multi-thread environment.

If I take MegaNode from MegaApi and pass it to different MegaApi for Upload/Download
then Upload/Download does not work. Looks like MegaApi requires own Nodes to operate for Upload/Download.

but I can not allow to FetchAllNodes for every MegaApi instance in every thread because that is going to be network latency issue.

thanks in advance,

from sdk.

javiserrano avatar javiserrano commented on September 13, 2024

MegaNodes can be used with different MegaApi instances, but they must be logged in and should have fetched the nodes of the account.

The best approach would be to use the same MegaApi object on all your threads because it's thread-safe.

from sdk.

dima72 avatar dima72 commented on September 13, 2024

Dear Javi,

what method do you mean for 'should have fetched the nodes of the account' ?
unless you mean MegaApi->fetchNodes().

I care that MegaApi->fetchNodes() is a bottleneck is used for every thread!

Probably I can not use singe MegaApi object for all threads since
because I need Upload/Download progress to be reported

thanks, for supporting me

from sdk.

javiserrano avatar javiserrano commented on September 13, 2024

I was talking about that function indeed.

It's not good to have several instances of MegaApi using the same account because, as you say, it's time consuming and every instance would take a significative amount of RAM, especially if the account contains many nodes.

You can get the progress of transfers using MegaTranferListener objects. If you set one using MegaApi::addTransferListener you would get information about all transfers there.

But since it seems that you need to keep transfers isolated somehow, you can pass a different listener for each transfer in the last parameter of MegaApi::startDownload / MegaApi::startUpload.

That way, you can receive callbacks about only one transfer or you can also share the same listener for a group of transfers if you want.

Another option would be to create public nodes for the files using MegaApi::getPublicNode. The resulting MegaNodes could be used in a different MegaApi instance even if it isn't logged in. But it's not very optimal because that function has to access servers to export the nodes.

I think that a smart management of listeners would be the best option for most use cases, but I don't know the details or your software so maybe it's not the best for you.

We are also testing a new way to share MegaNodes between MegaApi instances using an authentication token to allow downloads with non logged in instances of MegaApi, but it's not 100% ready yet. If you think that it would be the best option for you, maybe we could speed up that development a bit.

from sdk.

dima72 avatar dima72 commented on September 13, 2024

to report Upload/Download progress, probably I can use transfer->getNodeHandle in listener onTransferUpdate event, so probably I can distinguish file progress from another.

from sdk.

dima72 avatar dima72 commented on September 13, 2024

Javi,
I will test the proposed approach with different listener for each transfer and let you know.

thank you very much!

from sdk.

dima72 avatar dima72 commented on September 13, 2024

Javi,

thank you very much!!
Upload/Download with listener per thread and common MegaApi works fine.

there is no need to megaApi->removeListener for Upload/Download method, I hope they are removed internally when work is done.
Progress of particular file might be traced by transfer->getNodeHandle

from sdk.

javiserrano avatar javiserrano commented on September 13, 2024

I'm glad to see that things start working for you :-)

As you say, it's not needed to use removeTransferListener for listeners used with startUpload / startDownload. It's only needed for global transfer listeners, added with addTransferListener.

There is also a unique identifier per transfer (MegaTransfer::getTag) that you could use to trace transfers too.

from sdk.

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.