Closed AliAryanTech closed 1 year ago
I'm quite confused on what you're trying to do, I don't know your JavaScript background, but seems you are mistaking how asynchronous JavaScript works.
Do you know how to use Promises? And how about callbacks? If not check some tutorial for those topics first.
storage.ready
is a Promise, so seems you're missing an await
keyword, but at the same time you defined a callback at the same time, which… is weird. Use one or another. Callbacks is the old pattern, promises is the new one, this library support both because backyards compatibility but I recommend learning and using promises as they avoid some issues that callbacks have (like nesting hell).
Seems you are using Node CJS, it does not support top level await, check examples in mega.js.org to workaround this limitation (use a async IIFE). If possible learn and use ESM, it does not have this limitation.
Try learning about async patterns in JavaScript, them fix the login first, that's a lot for now, I will answer the upload question later.
I'm on the mobile client, when I get home I will move this into a discussion because that's not an issue with the library.
Describe the bug Well, I'm trying to test .upload but the terminal saying it's not a function? even I tried all examples of .upload it's saying it's not a function. also storage.once(), saying the same it's not a function.
To Reproduce
Expected behavior I tried in termux & replit it test the code! Termux
Replit:
Additional context One more thing can you tell me an example with a Buffer? Like how to upload a Buffer, I saw those example but coz of upload function unable to test upload by buffer, that's why I thought it would be better if you tell me an example!!
Like this? That's just a buffer, I don't know what's the file name and size!? Then why this,
allowUploadBuffering: true