Comments (14)
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.
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.
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.
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.
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.
I see,
thanks.
from sdk.
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.
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.
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.
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.
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.
Javi,
I will test the proposed approach with different listener for each transfer and let you know.
thank you very much!
from sdk.
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.
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)
- glibcxx assertions trip on tests HOT 2
- Session resume with megasimplesync
- Python - MegaNode.getChildren() always returns None HOT 1
- We need golang sdk or sdk examples. HOT 1
- FTP won't connect anywhere but PC? HOT 1
- sdk-5.1.2 build fail HOT 1
- Compilation support on various BSDs
- unable to compile megafuse
- How to use on Windows with Java?
- Is there any sdk based on c#?
- Account freezing and getting -3 (API_EAGAIN)
- Account-level deduplication
- Ask
- Ask
- Build final command is failing on any windows system with VS2017 or VS2022 as VS2019 is hardcoded in build_from_scratch.cmake
- Compile error: `std::recursive_mutex` has no member named `owns_lock` HOT 1
- Filesystem mismatch, leading to sync creation failure HOT 6
- configure: error: unicode/uchar.h header not found or not usable
- Does not build with Visual studio 2022 Community version. Looks for only Microsoft Visual Studio 2019 or 2017 which is no more available.
- Ask
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.