All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.eliux.mega.auth.MegaAuthFolder Maven / Gradle / Ivy

Go to download

Java client library that works on top of MEGAcmd to provide access to the services of Mega.nz

The newest version!
package io.github.eliux.mega.auth;

import io.github.eliux.mega.MegaSession;
import io.github.eliux.mega.cmd.MegaCmdLogin;
import io.github.eliux.mega.error.MegaLoginException;

/**
 * Authenticates the users into MEGA just for an exported or public folder
 */
public class MegaAuthFolder extends MegaAuth {

    private final String folderPath;

    public MegaAuthFolder(String folderPath) {
        this.folderPath = folderPath;
    }

    public String getFolderPath() {
        return folderPath;
    }

    @Override
    public MegaSession login() throws MegaLoginException {
        try {
            final MegaCmdLogin megaCmdLogin = new MegaCmdLogin(folderPath);
            megaCmdLogin.run();
            return new MegaSession(this);
        } catch (Throwable cause) {
            throw new MegaLoginException(
                    "You could not access to ".concat(folderPath), cause
            );
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy