code: protected void uploadDirectory(final FTPClient ftpClient, final String sourceDirectoryPath,
                                     final String targetDirectoryPath, final String logPrefix) throws IOException {
          log.info(String.format(UPLOAD_DIR, logPrefix, sourceDirectoryPath, targetDirectoryPath));
          final File sourceDirectory = new File(sourceDirectoryPath);
          final File[] files = sourceDirectory.listFiles();
          if (files == null || files.length == 0) {
              log.info(String.format("%sEmpty directory at %s", logPrefix, sourceDirectoryPath));
              return;
          }
  
          // Make sure target directory exists
          final boolean isTargetDirectoryExist = ftpClient.changeWorkingDirectory(targetDirectoryPath);
          if (!isTargetDirectoryExist) {
              ftpClient.makeDirectory(targetDirectoryPath);
          }
  
          final String nextLevelPrefix = logPrefix + "..";
          for (final File file : files) {
              if (file.isFile()) {
                  uploadFile(ftpClient, file.getAbsolutePath(), targetDirectoryPath, nextLevelPrefix);
              } else {
                  uploadDirectory(ftpClient, Paths.get(sourceDirectoryPath, file.getName()).toString(),
                          targetDirectoryPath + "/" + file.getName(), nextLevelPrefix);
              }
          }
      }
docs: Recursively upload a directory to FTP server with the provided FTP client object.
  
  @param sourceDirectoryPath
  @param targetDirectoryPath
  @param logPrefix
  @throws IOException