VFS SFTP upload sending directory structure, not just file

550 views Asked by At

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!

1

There are 1 answers

0
tim_yates On BEST ANSWER

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