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

io.github.eliux.mega.cmd.MegaCmdPutMultiple 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.cmd;

import io.github.eliux.mega.error.MegaWrongArgumentsException;
import java.util.*;

public class MegaCmdPutMultiple extends AbstractMegaCmdPut {

    private String remotePath;

    private List localFiles;

    public MegaCmdPutMultiple(String remotePath, String... localFiles) {
        this.remotePath = remotePath;
        this.localFiles = new ArrayList<>(Arrays.asList(localFiles));
    }

    public String getRemotePath() {
        return remotePath;
    }

    public MegaCmdPutMultiple setRemotePath(String remotePath) {
        if (remotePath != null) {
            this.remotePath = remotePath;
        }

        return this;
    }

    public List localFiles() {
        return localFiles;
    }

    private List cmdLocalFilesParams() {
        if (localFiles == null || localFiles.isEmpty()) {
            throw new MegaWrongArgumentsException(
                    "There are not local files specified!"
            );
        }

        return Collections.unmodifiableList(localFiles);
    }

    @Override
    protected List cmdFileParams() {
        List result = new LinkedList<>(localFiles);

        result.add(getRemotePath());

        return result;
    }

    public void addLocalFileToUpload(String filename) {
        localFiles.add(filename);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy