public void chdir( String dirToChangeTo ) throws KettleJobException { try { c.cd( dirToChangeTo.replace( "\\\\", "/" ). replace( "\\", "/" ) ); } catch ( SftpException e ) { throw new KettleJobException( e ); } }
/** * 打开指定目录,如果指定路径非目录或不存在返回false * * @param directory directory * @return 是否打开目录 */ @Override public boolean cd(String directory) { if (StrUtil.isBlank(directory)) { return false; } try { channel.cd(directory.replaceAll("\\\\", "/")); return true; } catch (SftpException e) { return false; } }
/** * 打开指定目录,如果指定路径非目录或不存在返回false * * @param directory directory * @return 是否打开目录 */ @Override public boolean cd(String directory) { if (StrUtil.isBlank(directory)) { return false; } try { channel.cd(directory.replaceAll("\\\\", "/")); return true; } catch (SftpException e) { return false; } }
logger.debug(proc + " attempting to change directory from " + currentWorkingDirectory + " to " + dir.getPath()); sftp.cd(forwardPaths); dirExists = true; logger.debug(proc + " changed working directory to '" + forwardPaths + "' from '" + currentWorkingDirectory + "'"); sftp.cd(dirName); } catch (final SftpException sftpe) { logger.debug(proc + " creating new directory and changing to it " + dirName); try { sftp.mkdir(dirName); sftp.cd(dirName); } catch (final SftpException e) { throw new IOException(proc + " could not make/change directory to [" + dirName + "] [" + e.getLocalizedMessage() + "]", e);
System.out.println("sftp channel opened and connected."); channelSftp = (ChannelSftp) channel; channelSftp.cd(SFTPWORKINGDIR); File f = new File(fileName); channelSftp.put(new FileInputStream(f), f.getName());
@Override public void cd(String path) throws IOException { map(() -> { ftp.cd(path); return null; }); }
ChannelSftp sftpChannel = (ChannelSftp) channel; writeToSDFile("9"); try { sftpChannel.cd("/home/john/Desktop"); String inputFileName =Environment.getExternalStorageDirectory().getAbsolutePath()+"/download/myData.txt"; File f = new File(inputFileName); sftpChannel.put(inputFileName, "/home/john/Desktop/myData.txt"); } catch (SftpException e) { writeToSDFile("sftp---exception"+e); }
public void cd(String path) throws SftpException { path = normalizePath(path); sftpChannel.cd(path); } }
private void doChangeDirectory(String path) { if (path == null || ".".equals(path) || ObjectHelper.isEmpty(path)) { return; } LOG.trace("Changing directory: {}", path); try { channel.cd(path); } catch (SftpException e) { throw new GenericFileOperationFailedException("Cannot change directory to: " + path, e); } }
public void cd(ProtocolFile file) throws ProtocolException { try { sftpChannel.cd(file.getPath()); } catch (Exception e) { throw new ProtocolException("Failed to cd to " + file + " : " + e.getMessage()); } }
public static void uploadFile(String hostname, int port, String username, File keyFile, final String passphrase, File file, String destinationFolder) throws JSchException, IOException, SftpException { Session session = createSession(hostname, port, username, keyFile, passphrase); session.connect(); ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); channel.connect(); channel.cd(destinationFolder); channel.put(new FileInputStream(file), file.getName()); channel.disconnect(); session.disconnect(); }
public static void uploadFile(String hostname, int port, String username, File keyFile, final String passphrase, File file, String destinationFolder) throws JSchException, IOException, SftpException { Session session = createSession(hostname, port, username, keyFile, passphrase); session.connect(); ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); channel.connect(); channel.cd(destinationFolder); channel.put(new FileInputStream(file), file.getName()); channel.disconnect(); session.disconnect(); }
@Override public void cd(Path path) throws SshException { try { this.channel.cd(PathHelper.toString(path)); this.workingDir = path; } catch (SftpException e) { throw convertSftpException(e); } }
private void mkdirs( String resourceName, int mode ) throws SftpException, TransferFailedException { String[] dirs = PathUtils.dirnames( resourceName ); for ( String dir : dirs ) { mkdir( dir, mode ); channel.cd( dir ); } }
public static void uploadFile(String hostname, int port, String username, File keyFile, final String passphrase, byte[] data, String destinationFolder, String destinationFileName) throws JSchException, IOException, SftpException { Session session = createSession(hostname, port, username, keyFile, passphrase); session.connect(); ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); channel.connect(); channel.cd(destinationFolder); channel.put(new ByteArrayInputStream(data), destinationFileName); channel.disconnect(); session.disconnect(); }
public static void uploadFile(String hostname, int port, String username, File keyFile, final String passphrase, byte[] data, String destinationFolder, String destinationFileName) throws JSchException, IOException, SftpException { Session session = createSession(hostname, port, username, keyFile, passphrase); session.connect(); ChannelSftp channel = (ChannelSftp) session.openChannel("sftp"); channel.connect(); channel.cd(destinationFolder); channel.put(new ByteArrayInputStream(data), destinationFileName); channel.disconnect(); session.disconnect(); }
void initializePostConnect(ChannelSftp channel) throws IOException { String defaultDir = FileSystemProviderSupport.getValue(this, DEFAULT_DIR, String.class, null); if (defaultDir != null) { try { channel.cd(defaultDir); } catch (SftpException e) { throw getExceptionFactory().createChangeWorkingDirectoryException(defaultDir, e); } } }