tonistiigi/mega

mkdir function

Closed this issue · 5 comments

Hi tonistiigi, I'm using your library and is great but I need create directories and I see that this is a missing function.

Do you know if exists another way to create a directory using you library?

Sorry for my english, thanks!

mkdir is a defined request in mega api. There just isn't a function in this library that does this request.

Simplest is just to trace the request json with web inspector and use the api.request() to make the call. https://github.com/tonistiigi/mega/blob/master/lib/api.js#L41

I'm bit busy now but if you still need it I could probably add it in a week or two. If you add it yourself then make a pull request.

I try to help you with this function but I don't understand how it's work the last parameters (h, a and k) in the json, only I found is...to create a dir you need set the flag n.h with 1

a: 'p',
t: opt.target.nodeId ? opt.target.nodeId : opt.target,
n: [{
h: (I don't know),
t: 1,
a: (I don't know),
k: (I don't know)
}]}

Yes, its a bit more complicated but its the same command that is used for uploading a file. Just instead of posting a file hash for directory you use h=xxxxxxxx and t=1.

k - encrypted generated key
a - packed encrypted attributes object(contains the name)

https://github.com/tonistiigi/mega/blob/master/lib/storage.js#L325

mkdir() added with edbeae8

:D thanks tonistiigi!!!!