code: private void upload(String fileOrDir, String uploadRootDir) throws Exception {
          if (uploadRootDir.isEmpty())
              uploadRootDir = ".";
          File origin = new File(fileOrDir);
  
          if (fileOrDir.endsWith(".tar") || fileOrDir.endsWith(".tar.gz")) {
              upload(new File(fileOrDir), uploadRootDir);
              untar(uploadRootDir);
          } else if (origin.isFile()) {
              upload(new File(fileOrDir), uploadRootDir);
          } else {
              File[] childFiles = origin.listFiles();
              if (childFiles != null)
                  upload(Arrays.asList(childFiles), uploadRootDir);
  
          }
      }
docs: uploads the file or listed files in a directory