diff --git a/src/main/java/org/embulk/output/sftp/SftpFileOutput.java b/src/main/java/org/embulk/output/sftp/SftpFileOutput.java index 8ca6b4e..2838012 100644 --- a/src/main/java/org/embulk/output/sftp/SftpFileOutput.java +++ b/src/main/java/org/embulk/output/sftp/SftpFileOutput.java @@ -216,7 +216,15 @@ private FileObject newSftpFile(URI sftpUri) int count = 0; while (true) { try { - return manager.resolveFile(sftpUri.toString(), fsOptions); + FileObject file = manager.resolveFile(sftpUri.toString(), fsOptions); + if (file.getParent().exists()) { + logger.info("parent directory {} exists there", file.getParent()); + return file; + } + else { + logger.info("trying to create parent directory {}", file.getParent()); + file.getParent().createFolder(); + } } catch (FileSystemException e) { if (++count == maxConnectionRetry) {