@Override public int copyToServer(Map<String,?> props, InputStream contents, String pathAndFileOnRemoteServer) { /* sshj needs to: * 1) to know the length of the InputStream to copy the file to perform copy; and * 2) re-read the input stream on retry if the first attempt fails. * For now, write it to a file, unless caller supplies a KnownSizeInputStream * * (We could have a switch where we hold it in memory if less than some max size, * but most the routines should supply a string or byte array or similar, * so we probably don't come here too often.) */ if (contents instanceof KnownSizeInputStream) { return copyToServer(props, Suppliers.ofInstance(contents), ((KnownSizeInputStream)contents).length(), pathAndFileOnRemoteServer); } else { File tempFile = writeTempFile(contents); try { return copyToServer(props, tempFile, pathAndFileOnRemoteServer); } finally { tempFile.delete(); } } }