Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request : Able to generate public link for a folder #18

Open
Cartmanishere opened this issue Mar 5, 2019 · 3 comments
Open

Comments

@Cartmanishere
Copy link

Cartmanishere commented Mar 5, 2019

Currently the folder node does not generate a valid public link. I think it would be useful feature to be able to export folders.

I have tried to do this myself but there's little to no directions on how to use the API to implement something like this.

In case you do not want to include this feature in the library, any hints regarding how it could be done is also appreciated.

@ncw
Copy link
Collaborator

ncw commented Mar 6, 2019

Which backend are you talking about?

rclone link should work for both files and folders so if it doesn't work then that is a bug.

@Cartmanishere
Copy link
Author

Not really trying to use this through rclone but trying to use this library to make my own client.

I'll give an example of what I meant when I said folder node does not generate a valid public link.

image

Here I have a test account with one File and one Folder.

Now I try to export both the File and Folder for public download using the go-mega library.

I use the following code (paraphrased) -

m := mega.New()
m.Login(username, password)
fs := m.FS
root := fs.GetRoot()
children, err := fs.GetChildren(node)
for _, child := range children {
	link, err := m.Link(child, true)
	if err != nil {
		link = err.Error()
	}
	fmt.Println(child.GetName(), link)
}

The above code return me the following -

Folder https://mega.co.nz/#!I7ImUArT!X67zZ7mBlUUXijs79Gc7GQ
File.pdf https://mega.co.nz/#!xqp2wYKA!6VuXOcqaqUkCzb3D-6ga7oSenpOO1SEJWI1cSKFurOU

Now I will export the link for both of them from the browser and this is what I get -

Folder https://mega.nz/#F!I7ImUArT!UwOHhYWcfVSU7wuR90SdVQ
File.pdf https://mega.nz/#!xqp2wYKA!6VuXOcqaqUkCzb3D-6ga7oSenpOO1SEJWI1cSKFurOU

You can see that the file link is correct but the Folder links differ in their Decryption Keys. Correct folder also has the format like #F! which marks it as a folder link.

Since rclone uses go-mega, it also exports wrong folder link. So I guess it is a bug.

After looking into the Link(n *Node, includeKey bool) (string, error) function, I see that files and folders are exported the same.

But after observing the api requests in the browser while exporting Folder links, you can clearly see that different procedures are followed for exporting Files and Folders in Mega API.

Unfortunately I couldn't exactly figure out how the Folder exporting API works, otherwise I was going to implement it myself and make a pull request.

@ncw
Copy link
Collaborator

ncw commented Mar 7, 2019

Not really trying to use this through rclone but trying to use this library to make my own client.

Sorry, I thought I was responding to an rclone bug report!

But after observing the api requests in the browser while exporting Folder links, you can clearly see that different procedures are followed for exporting Files and Folders in Mega API.

Ah... This library has been 100% reverse engineered (there are no specs for the API) so a bit of sleuthing will be required to fix this.

Here is the relevant code in the C++ SDK

https://github.com/meganz/sdk/blob/7e38fe118ddb0fc0a83f90a7032a95ea39a83a47/src/megaclient.cpp#L9529

Can you figure out what it is doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@ncw @Cartmanishere and others