What is filename
? I suspect buildSftpPath(filename, ph)
is building the full directory structure... Try buildSftpPath(new File( filename ).name, ph)
VFS SFTP upload sending directory structure, not just file
-
28-06-2022 - |
Pregunta
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!
Solución
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow