문제

I am attempting to upload a file to an SFTP site, but the entire directory structure is being recreated on the SFTP site instead of just uploading the file at the root. I am calling sendSftp (see below).

public void sendSftp(String filename, IPropertyHelper ph) {
    def local = VFS.getManager().toFileObject(new File("${filename}"))
    def remote = VFS.getManager().resolveFile(buildSftpPath(filename, ph), new FileSystemOptions());
    remote.copyFrom(local, Selectors.SELECT_SELF) 
}

private String buildSftpPath(filename, IPropertyHelper ph) {
    return "sftp://${ph.properties.sftp_Login}:${ph.properties.sftp_Password}@${ph.properties.sftp_Hostname}/${filename}"
}

Any help in how to send just the file and place it at the root of the SFTP site would be great, thanks!

도움이 되었습니까?

해결책

What is filename? I suspect buildSftpPath(filename, ph) is building the full directory structure... Try buildSftpPath(new File( filename ).name, ph)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top