I'm trying to copy a single file in the local file system to a remote SFTP server using Apache Commons VFS. to mimic the actual problem, I have written the following code which generates the same issue.
FileSystemManager fileSystemManager = VFS.getManager();
FileObject fileToCopy = fileSystemManager.resolveFile("/tmp/submission/2004220.csv");
FileObject destinationDirectory = fileSystemManager.resolveFile("/tmp/test");
destinationDirectory.copyFrom(fileToCopy,Selectors.SELECT_SELF);
When the above code executed, the /tmp/test
directory is converted to a file instead of copying the 2004220.csv
file into /tmp/test
folder. I was able to successfully copy files between two folders by selecting all files as children through a Selectors.SELECT_CHILDREN
Fileselector, but facing this problem only when copying a single file to a directory.