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);
}
}
Aggregations