Search in sources :

Example 16 with AzureDockerException

use of com.microsoft.azure.docker.model.AzureDockerException in project azure-tools-for-java by Microsoft.

the class AzureDockerSSHOps method upload.

public static void upload(Session session, String fileName, String fromPath, String toPath, boolean isUserHomeBased, String filePerm) {
    try {
        FileInputStream inputStream = new FileInputStream(fromPath + File.separator + fileName);
        ChannelSftp channel = (ChannelSftp) session.openChannel("sftp");
        channel.connect();
        String absolutePath = isUserHomeBased ? channel.getHome() + "/" + toPath : toPath;
        String path = "";
        for (String dir : absolutePath.split("/")) {
            path = path + "/" + dir;
            try {
                channel.mkdir(path);
            } catch (Exception ee) {
            }
        }
        channel.cd(toPath);
        channel.put(inputStream, fileName);
        channel.disconnect();
    } catch (Exception e) {
        throw new AzureDockerException(e.getMessage(), e);
    }
}
Also used : AzureDockerException(com.microsoft.azure.docker.model.AzureDockerException) AzureDockerException(com.microsoft.azure.docker.model.AzureDockerException)

Aggregations

AzureDockerException (com.microsoft.azure.docker.model.AzureDockerException)16 CloudException (com.microsoft.azure.CloudException)9 AzureDockerCertVault (com.microsoft.azure.docker.model.AzureDockerCertVault)8 Vault (com.microsoft.azure.management.keyvault.Vault)3 FileWriter (java.io.FileWriter)3 JSch (com.jcraft.jsch.JSch)2 KeyPair (com.jcraft.jsch.KeyPair)2 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AzureDockerUtils (com.microsoft.azure.docker.ops.utils.AzureDockerUtils)1 DEBUG (com.microsoft.azure.docker.ops.utils.AzureDockerUtils.DEBUG)1 KeyVaultClient (com.microsoft.azure.keyvault.KeyVaultClient)1 SecretBundle (com.microsoft.azure.keyvault.models.SecretBundle)1 SetSecretRequest (com.microsoft.azure.keyvault.requests.SetSecretRequest)1 Azure (com.microsoft.azure.management.Azure)1 SecretPermissions (com.microsoft.azure.management.keyvault.SecretPermissions)1 Pair (com.microsoft.azuretools.utils.Pair)1 ServiceCallback (com.microsoft.rest.ServiceCallback)1